function_exists

bool function_exists(string function_name) 

Determines whether a function is defined.

Returns:

TRUE if the function exists; FALSE otherwise

Description:

function_exists() is used to determine whether the given function is defined in the current PHP environment.

Availability:

UNIX, Windows

Version:

3.0.7+, 4+

See also:

To find out whether a given method or class is defined:

method_exists() 
class_exists() 

Example:

Find out whether a function exists
$function_name = 'get_big_raise'; 

if (function_exists ($function_name)) 
    print "Function <tt>$function_name</tt> exists (and there was much rejoicing)."; 
else 
    print "Function <tt>$function_name</tt> does not exist."; 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.