If compatibility with various PHP versions is especially important to your script, it's useful to be able to check for the existence of functions. The function function_exists does that what you'd expect. It takes a string with a function's name and returns TRUE or FALSE depending on whether the function has been defined.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"> <head> <title>PHP</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php $test=function_exists("test_this"); if ($test == TRUE) { echo "Fucntion test_this exists."; } else { echo "Function test_this does not exist."; } ?> </p> </body> </html> |