Current Location: Home> Function Categories> is_callable

is_callable

Detect whether the parameters are legal callable structures
Name:is_callable
Category:Variable processing
Programming Language:php
One-line Description:Check whether the content of the variable can be called as a function.

Definition and usage

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.

Example

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

grammar

 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).
Similar Functions
Popular Articles