Create a PHP Documentation Bookmarklet

Here's an easy javascript tip that'll make looking up PHP functiosn even faster.
Create a  PHP Documentation Bookmarklet

Most PHP programmers I know (including myself) visit the PHP function reference daily, if not hourly. Going to is a quick way to lookup the specs on a particular function, reserved word, or anything else in the language. Here’s an easy javascript tip that’ll make looking up PHP functions even faster.

Just drag this link to your browser’s bookmark bar. Now, when you click on it, you’ll be prompted to enter a function name. Hit enter, and you’ll be automagically taken to the correct PHP reference page.

But we’re not done yet! If you’re using Apple’s Safari browser we can even do this without using the mouse. Press command + <1…9> to jump straight to a specific bookmark. For example, command+3 will jump to the 3rd bookmark listed in your bookmark bar. So, stick our PHP bookmarklet in a 1 – 9 spot and you can do lookups without ever taking your hands off the keyboard.

So how does this magic bookmark work? The bookmark we added is really two lines of embedded javascript. The first line

var func = prompt("Enter a PHP function", "date");

prompts the user to enter a function name to lookup. In this example I’ve also given the prompt a default value of “date” since that is the function I visit most often. You can leave that field blank or fill it in with your own value.

The second line'' + func);

tells the browser to go to followed by the value you entered.

To complete the process we put both lines together with “javascript:” in front and bookmark the link.

Jon Henshaw
Co-Founder and President

Jon is the Co-founder and President of Raven Internet Marketing Tools.

Jon is the Co-founder and President of Raven Internet Marketing Tools.

  • Chris Wage

    While we’re at it, you can do this sort of thing with Opera, too, using their “quicksearches”. This will let you do “p sprintf” in the address bar:

    [Search Engine 10]
    Is post=0
    Has endseparator=0
    Search Type=1

  • Tyler Hall

    Aha! Great idea, Chris. I had previously added a PHP search to my Firefox search box, but never even thought about doing it for Opera. I’m going to add your code in right now :)

  • Rudolf

    Original script does not correctly processes CANCEL button in dialog and does not handle empty imput. Here is an improved version:
    javascript:var func=prompt(“PHP Function”);if((func!=null)&&(func!=”))“”+func)
    If user clicks CANCEL or does not input anything, nothing will happen.

  • ninware

    wow nice idea thanks