PHP is_callable() Function

❮ PHP Variable Handling Reference

Example

Check whether the contents of a variable can be called as a function or not:

<?php
function test1(){
}

echo "test1 is callable: " . is_callable("test1");
echo "<br>";
echo "test2 is callable: " . is_callable("test2");
?>
Try it Yourself »

Definition and Usage

The is_callable() function checks whether the contents of a variable can be called as a function or not.

This function returns true (1) if the variable is callable, otherwise it returns false/nothing.


Syntax

is_callable(variable, syntax_only, name );

Parameter Values

Parameter Description
variable Required. Specifies the variable to check
syntax_only Optional. If set to TRUE, the function only verifies if variable is a function or method. It will reject variables that are not strings, or arrays without a valid structure to be used as a callback. Default is false
name Optional. Returns a "callable name" (only for classes)

Technical Details

Return Value: TRUE if variable is callable, FALSE otherwise
Return Type: Boolean
PHP Version: 4.0.6+

❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.