PHP is_callable() Funktion
❮ Referenz zur Behandlung von PHP-Variablen
Beispiel
Überprüfen Sie, ob der Inhalt einer Variablen als Funktion aufgerufen werden kann oder nicht:
<?php
function test1(){
}
echo "test1 is callable: " . is_callable("test1");
echo "<br>";
echo "test2 is callable: " . is_callable("test2");
?>
Definition und Verwendung
Die Funktion is_callable() prüft, ob der Inhalt einer Variablen als Funktion aufgerufen werden kann oder nicht.
Diese Funktion gibt wahr (1) zurück, wenn die Variable aufrufbar ist, andernfalls gibt sie falsch/nichts zurück.
Syntax
is_callable(variable, syntax_only, name );
Parameterwerte
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
Rückgabewert: | TRUE, wenn Variable aufrufbar ist, sonst FALSE |
---|---|
Rückgabetyp: | Boolesch |
PHP-Version: | 4.0.6+ |
❮ Referenz zur Behandlung von PHP-Variablen