Funkce PHP is_callable().
❮ Reference manipulace s proměnnými PHP
Příklad
Zkontrolujte, zda lze obsah proměnné volat jako funkci nebo ne:
<?php
function test1(){
}
echo "test1 is callable: " . is_callable("test1");
echo "<br>";
echo "test2 is callable: " . is_callable("test2");
?>
Definice a použití
Funkce is_callable() kontroluje, zda lze obsah proměnné volat jako funkci nebo ne.
Tato funkce vrací true (1), pokud je proměnná volatelná, jinak vrací false/nic.
Syntax
is_callable(variable, syntax_only, name );
Hodnoty parametrů
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) |
Technické údaje
Návratová hodnota: | TRUE, pokud je proměnná volatelná, FALSE v opačném případě |
---|---|
Typ vrácení: | Boolean |
Verze PHP: | 4.0.6+ |
❮ Reference manipulace s proměnnými PHP