is_bool()
This function simply returns true if the given variable contains a boolean value, or false if it doesn’t.
Where this might come in handy is checking those values which act the same as true and false (1 and 0) but where you do or do not want to allow for a boolean value.
$t = true; $f = false; $z = 0; // the following two examples are identical $res = ( true === $t || false === $t ); $res = is_bool($t); $res = ( empty($z) && !is_bool($z) ); // true && true = true $res = ( empty($f) && !is_bool($f) ); // true && false = false $res = ( $t > 0 and !is_bool($t) ); // true && false = false
