is_callable
Verify that a value can be called as a function from the current scope.
is_callable Function synopsis
is_callable(
mixed $value,
bool $syntax_only = false,
&$callable_name = null
): bool
Parameters
$value
Typemixed
The value to be checked.
$syntax_only
OptionalTypeboolDefault valuefalse
If set to true the function only verifies that
$value might be a function or method. It will
reject any values that are not invokable objects,
Closure, strings, or arrays that do not have
a valid structure to be used as a callback. A valid callable array
has 2 entries, the first of which is an object
or a string, and the second a string.
$callable_name
Passed by reference, OptionalDefault valuenull
Receives the "callable name", e.g.
"SomeClass::someMethod". Note, however, that despite
the implication that SomeClass::someMethod() is a
callable static method, this is not the case.
Note that the parameter
$callable_nameis passed by reference, and contains additional/updated context data that may be useful.
Return value
Typebool
Returns true if $value is callable, false
otherwise.
Changes to the is_callable Function
PHP 8.0
- Return type added:
bool - Parameter name of parameter #1 changed:
$varto$value - Parameter type added for parameter #1 (
$value):mixed - Parameter type added for parameter #2 (
$syntax_only):bool - Parameter default value added for position #2 (
$syntax_only):false - Parameter default value added for position #3 (
$callable_name):null
is_callable(
- $var,
+ mixed $value,
- $syntax_only,
+ bool $syntax_only = false,
- &$callable_name
+ &$callable_name = null
- )
+ ): bool is_callable Function Availability
is_callable Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Future Release | Yes |
| PHP 8.5Upcoming Release | Yes |
| PHP 8.4Supported (Latest) | Yes |
| PHP 8.3Supported | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Security-Fixes Only | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |