Name
function_exists()
Synopsis
bool function_exists ( string function_name )If you're working with functions that are not part of the PHP core (i.e., that need to be enabled by users), it's a smart move to use the function_exists() function. This takes a function name as its only parameter and returns true if that function (either built-in or one you've defined yourself) is available for use. It only checks whether the function is available, not whether it will work—your system may not be configured properly for some functions. Here is how it looks in code:
if (function_exists("imagepng")) {
echo "You have the GD extension loaded.";
} else {
echo "Can't find imagepng() - do you have GD loaded?";
}Tip
If you ever want to know whether you have a function available to you, use the function_exists() function. This takes one string parameter that is the name of a function and returns true if the function exists or false if it does not. Many people use function_exists() to find out whether they have an extension available, by calling function_exists() on a function of that extension. However, this is accomplished more easily with the extension_loaded() function, covered in the next section.