The is_bool() function is used to detect whether a variable is of Boolean type.
PHP version requirements: PHP 4, PHP 5, PHP 7
grammar
bool is_bool (mixed $var)
Parameter description:
$var: The variable to be tested.
return value
Returns TRUE if var is boolean.
Example
Example
<?php $a = false ; $b = 0 ; // Because $a is Boolean, the result is true if ( is_bool ( $a ) ) { print " Variable a is of type Boolean " ; } // Because $b is not a boolean, the result is false if ( is_bool ( $b ) ) { print " Variable b is of type Boolean " ; } ?> The output is:
Variable a is of type Boolean