PHP is_bool()-Funktion

PHP 可用的函数Verfügbare PHP-Funktionen

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

<?php $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 是布尔型

PHP 可用的函数Verfügbare PHP-Funktionen

Andere Erweiterungen