Sometimes we develop PHP scripts that requires other 3rd party libraries or makes use of PHP4 or PHP5 specific functions. What we then forget is that when we upload it to a server with PHP4 on and we developed for PHP5, we’re going to end up with a lot of “function not found” errors.

Yes, PHP4 is old news, and everyone should be using PHP5 by now, but there are still a lot of times I come across the need for PHP4 development.

What I’ve started doing is making PHP4 equivalent functions. But this is not what this post is about, what I want to tell you about is the function_exists function.

if (function_exists(’FUNCTION_CALL’)) {
  FUNCTION_CALL();
}

You can define your own function by doing this:

if (!function_exists(’FUNCTION_CALL’)) {
  function FUNCTION_CALL() {
    echo "this function does something";
  }
}

The above will only create your own function is the function doesn’t already exist.