Menu Samaritan's Purse

IS_CALLABLE

Verify that the contents of a variable can be called as a function

SYNTAX

is_callable ( mixed $var [, bool $syntax_only = FALSE [, string &$callable_name ]] ) : bool

PARAMETERS

var

The value to check

syntax_only

If set to TRUE the function only verifies that var 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

Receives the "callable name".

RETURN

Returns TRUE if var is callable, FALSE otherwise.

EXAMPLES

VAR | FUNCTION

1

VAR | METHOD

1

SYNTAX_ONLY | FUNCTION

1

SYNTAX_ONLY | METHOD

1

CALLABLE_NAME | FUNCTION

1
myfunction

CALLABLE_NAME | METHOD

1
myclass::myfunction

PHP