PHP is_bool() Function
❮ PHP Variable Handling Reference
Example
Check whether a variable is a boolean or not:
<?php
$a = 1;
echo "a is " . is_bool($a) . "<br>";
$b = 0;
echo "b is
" . is_bool($b) . "<br>";
$c =
true;
echo "c is " . is_bool($c) .
"<br>";
$d = false;
echo "d is " . is_bool($d) . "<br>";
?>
Try it Yourself »
Definition and Usage
The is_array() function checks whether a variable is a boolean or not.
This function returns true (1) if the variable is a boolean, otherwise it returns false/nothing.
Syntax
is_boolean(variable);
Parameter Values
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Technical Details
Return Value: | TRUE if variable is a boolean, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
❮ PHP Variable Handling Reference