The most useful PHP function?

I know that PHP has a lot of functions built right in, some of which are used frequently and some sparingly. But what about "home made" functions that we've created? Which are the most used?

I tend to use dd() an awful lot. It's a simple wrapper for print_r() and I've found it very useful for outputting variables directly into the HTML source, so the output it generates is invisible unless you "view source" in the browser:

function dd($var, $cap = 'var') {
   echo "<!-- $cap = ";
   print_r($var);
   echo " -->\n";
}

By removing the HTML comment markers ("<!--" and "-->") from the above, it's easily adaptable to PHP CLI as well.

Due to the large volume of spam, comments are disabled. If you have anything relevant to say, you can leave a , or contact me directly.

About the author

Ivan's mugshotI'm Ivan Lutrov and I'm the owner of Lutrov Interactive. I have 25 years of experience producing interactive work and I create cost effective business websites that are simple, engaging and easy to use. I practice what I preach and I say what I really think, even if it's sometimes not what you want to hear. Subscribe to the Lutrov Interactive feed via RSS and follow me on Twitter.