PHP is_bool()-Funktion
is_bool()Die Funktion wird verwendet, um festzustellen, ob eine Variable boolesch ist.
PHP-Versionsanforderungen: PHP 4, PHP 5, PHP 7
Syntax
bool is_bool ( mixed $var )
Parameterbeschreibung:
- $var: Die zu prüfende Variable.
Rückgabewert
Gibt TRUE zurück, wenn var boolesch ist.
Beispiel
Beispiel
$a = false;
$b = 0;
//Da $a boolesch ist, ist das Ergebnis true
if (is_bool($a)) {
print "Variable a ist boolesch";
}
//Da $b nicht boolesch ist, ist das Ergebnis false
if (is_bool($b)) {
print "Variable b ist boolesch";
}
Das Ausgabeergebnis ist:
变量 a 是布尔型Andere Erweiterungen
Verfügbare PHP-Funktionen