PHP is_callable() Function
is_callable() The function is used to check whether a function is callable in the current environment.
is_callable() The function verifies whether the content of a variable can be used as a function call. This can check a variable containing a valid function name, or an array containing a correctly encoded object and function name.
PHP version requirement: PHP 4 >= 4.0.6, PHP 5, PHP 7
Syntax
bool is_callable ( callable $name [, bool $syntax_only = false [, string &$callable_name ]] )
Parameter Description:
- $name: the callback function to check.
- $syntax_only: if set to TRUE, this function only verifies that name could be a function or method. It only rejects non-strings, or those that do not contain a valid structure usable as a callback. A valid one should contain two elements: the first is an object or string, and the second element is a string.
- $callable_name: accepts the "callable name".
Return Value
If name is callable, returns TRUE; otherwise returns FALSE.
Example
Example
The output is:
bool(true)
someFunction
bool(true)
someClass::someMethod
Available PHP Functions