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 check
$syntax_only
OptionalTypebool
Default valuefalse
If set to true
the function only verifies that
$value
might be a function or method. It will only
reject simple variables that are not strings, or an array that does
not have a valid structure to be used as a callback. The valid ones
are supposed to have only 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". In the example below it is "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_name
is 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:
$var
to$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 AvailabilityPHP Version | Availability |
---|---|
PHP 8.5Future Release | Yes |
PHP 8.4Upcoming Release | Yes |
PHP 8.3Supported (Latest) | Yes |
PHP 8.2Supported | 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 |