Create a  PHP Documentation Bookmarklet

Raven

Create a PHP Documentation Bookmarklet

Most PHP programmers I know (including myself) visit the PHP function reference daily, if not hourly. Going to http://php.net/ 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

window.open('http://php.net/' + func);

tells the browser to go to http://php.net/ followed by the value you entered.

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

Comments are closed on this post