PHP is_bool() Function
is_bool()The function is used to detect whether a variable is boolean.
PHP Version Requirements: PHP 4, PHP 5, PHP 7
Syntax
bool is_bool ( mixed $var )
Parameter Description:
- $var: The variable to be checked.
Return Value
Returns TRUE if var is boolean.
Example
Example
$a = false;
$b = 0;
//Because $a is boolean, the result is true
if (is_bool($a)) {
print "Variable a is boolean";
}
//Because $b is not boolean, the result is false
if (is_bool($b)) {
print "Variable b is boolean";
}
The output result is:
变量 a 是布尔型Other Extensions
PHP Available Functions