is_bool
Checks whether a value is a boolean.
Syntax
is_bool(mixed $value): boolParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | The value to check. |
Return value
bool`true` if the value is `true` or `false`.
Examples
A boolean and look-alikes:
<?php
var_dump(is_bool(false));
var_dump(is_bool(0));
var_dump(is_bool('true'));Output:
bool(true)
bool(false)
bool(false)Notes
This is how "nothing found" is told apart from a real value: strpos(), for instance, returns false rather than 0.
See also
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.