is_callable
Detect whether the parameters are legal callable structures
is_callable()
function checks whether the content of a variable can be called as a function.
If the variable is callable, the function returns true
(1), otherwise false
/ nothing is returned.
Check whether the content of a variable can be called as a function:
<?php function test1 ( ) { } echo "test1 is callable: " . is_callable ( "test1" ) ; echo "<br>" ; echo "test2 is callable: " . is_callable ( "test2" ) ; ?>
Try it yourself
is_callable ( variable , syntax_only , name ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |
syntax_only |
Optional. If set to TRUE, the function only verifies whether the variable is a function or method. It will reject variables that are not strings, or arrays that have no valid structures to use as callbacks. Default is false. |
name | Optional. Returns a "callable name" (for classes only). |