PHP is_callable() Function

PHP is_countable() Function
PHP is_bool() Function

In this article, you will learn how to check if a variable content can be called a function or not. Remember that, we can store function in a variable. The is_callable() function in PHP checks whether the contents of a variable can be called a function or not.

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

what is the syntax of the IS_CALLABLE() function in php?

is_callable(variable, syntax_only, name );
ParametersDetails
variableRequired. Specifies the variable to check
syntax_onlyOptional. 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
nameOptional. Returns a “callable name” (only for classes)
PHP is_callable() method

examples of the IS_CALLABLE() function

Example 1. In this example, we 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");
?>
PHP is_countable() Function
PHP is_bool() Function
en English
X
Scroll to Top