PHP | is_callable() Function Last Updated : 20 Jun, 2018 Comments Improve Suggest changes Like Article Like Report The is_callable() function is an inbuilt function in PHP which is used to verify the contents of a variable can be called as a function. It can check that a simple variable contains the name of a valid function, or that an array contains a properly encoded object and function name. Syntax: bool is_callable ( $variable_name, $syntax_only, $callable_name ) Parameters: The is_callable() function accepts three parameters as shown in above syntax and are described below. It depends on user to use how many parameters one, two or three. $variable_name: The name of a function stored in a string variable $variable_name, or an object and the name of a method within the object. $syntax_only: If set to TRUE the function only verifies that name might be a function or method. It will 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. This option only implemented for classes. Return value: This function returns a boolean type value. It returns TRUE if $variable_name is callable, FALSE otherwise. Below program illustrate the is_callable() function in PHP: Program 1: Simple variable contains a function php <?php // To check a variable if it can be called // as a function. // Declare the function function Function_xyz() { } $variable_name = "Function_xyz"; var_dump(is_callable($variable_name, false, $callable_name)); echo $callable_name, "\n"; // using only-one parameter var_dump(is_callable($variable_name)); ?> Output: bool(true) Function_xyz bool(true) Program 2: Array contains a method php <?php // To check a variable if it can be called // as a function. // Define class class ClassA { // Define method function Method_xyz() { } } // Object instance $obj = new ClassA(); $variable_name = array($obj, 'Method_xyz'); var_dump(is_callable($variable_name, true, $callable_name)); echo $callable_name, "\n"; ?> Output: bool(true) ClassA::Method_xyz Reference: http://php.net/manual/en/function.is-callable.php Comment More infoAdvertise with us Next Article PHP | is_callable() Function M Mithun Kumar Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | is_countable() Function The is_countable() function is an inbuilt function in PHP which is used to check whether the content of the variable is countable or not. Syntax: bool is_countable ( mixed $var ) Parameters: This function accepts one parameter as mentioned above and described below: $var: This parameter holds the va 1 min read PHP | is_a() function The is_a() is a built-in function in PHP and is used to check whether a given object is of a given class or not. It also checks if the given class is one of the parents of the given object or not. Syntax: boolean is_a($object, $class) Parameters: This function accepts two parameters as shown in the 2 min read PHP | is_double() Function The is_double() function is an inbuilt function in PHP which is used to find whether the given value is a double or not. Syntax: bool is_double( $variable_name ) Parameters: This function accepts one parameter as mentioned above and described below: $variable_name: This parameter holds the value whi 2 min read PHP is_file( ) Function The is_file() function in PHP is an inbuilt function which is used to check whether the specified file is a regular file or not. The name of the file is sent as a parameter to the is_file() function and it returns True if the file is a regular file else it returns False. Syntax: bool is_file($file) 2 min read PHP | is_array() Function The is_array() is an inbuilt function in PHP. The is_array() function is used to check whether a variable is an array or not. Syntax: bool is_array($variable_name) Parameter: This function accept a single parameter as mentioned above and described below: $variable_name: This parameter holds the vari 2 min read PHP is_float() Function PHP is_float() is an inbuilt function in PHP. The is_float() function is used to find whether a variable is a float or not. Syntax: boolean is_float($variable_name) Parameter: This function contains a single parameter as shown in the above syntax and described below $variable_name: the variable we w 2 min read PHP | is_dir( ) Function The is_dir() function in PHP used to check whether the specified file is a directory or not. The name of the file is sent as a parameter to the is_dir() function and it returns True if the file is a directory else it returns False. Syntax: is_dir($file) Parameters Used: The is_dir() function in PHP 1 min read PHP | get_class() Function The get_class() function is an inbuilt function in PHP which is used to return the class name of an object. Syntax: string get_class( object $object ) Parameters: This function accepts single parameter $object which holds the object that need to be tested. The value of this parameter can be omitted 1 min read PHP | intl_is_failure() Function The intl_is_failure() function is an inbuilt function in PHP which is used to check whether the given error code indicates failure. Syntax: bool intl_is_failure( $error_code ) Parameters: This function accepts single parameter $error_code which is a value that returned by the functions intl_get_erro 1 min read Like