PHP is_callable() Functie
❮ Referentie voor het afhandelen van PHP-variabelen
Voorbeeld
Controleer of de inhoud van een variabele kan worden aangeroepen als een functie of niet:
<?php
function test1(){
}
echo "test1 is callable: " . is_callable("test1");
echo "<br>";
echo "test2 is callable: " . is_callable("test2");
?>
Definitie en gebruik
De functie is_callable() controleert of de inhoud van een variabele kan worden aangeroepen als een functie of niet.
Deze functie retourneert true (1) als de variabele aanroepbaar is, anders wordt false/niets geretourneerd.
Syntaxis
is_callable(variable, syntax_only, name );
Parameterwaarden
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) |
Technische details
Winstwaarde: | TRUE als variabele aanroepbaar is, anders FALSE |
---|---|
Retourtype: | Booleaans |
PHP-versie: | 4.0.6+ |
❮ Referentie voor het afhandelen van PHP-variabelen