By using this function, we can check whether the variable is boolean variable or not.
bool is_bool ( mixed $var )
Parameter | Description | Is compulsory |
---|---|---|
var_name | The variable being evaluated. | compulsory |
It return True if var is boolean, False otherwise.
<?php $x=false; echo is_bool($x); ?>
Output:
<?php $y=false; if (is_bool($y)) echo 'This is a boolean type.'; else echo 'This is not a boolean type.'; ?>
Output: