function_exists()
function_exists() — Return true if the given function has been defined.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Checks the list of defined functions, both built-in (internal) and user-defined, for function.
Signature
function_exists(string $function): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $function | string | The function name, as a string. |
Return value
Returns true if function exists and is a function, false otherwise. Note: This function will return false for constructs, such as include_once and echo. This function will return false for constructs, such as include_once and echo.
Example
A runnable snippet:
if (function_exists('imap_open')) { echo "IMAP functions are available.<br />\n"; } else { echo "IMAP functions are not available.<br />\n"; }
See also
method_exists(), is_callable(), get_defined_functions(), class_exists(), extension_loaded()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page function_exists() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.