PHP Tutorial - PHP is_bool() function






is_bool(value) returns true if value is a Boolean.

Syntax

PHP is_bool() function has the following syntax.

is_bool(value)

Parameter

  • value is the variable being type checked.

Return

Returns true if value is a Boolean.





Example

Is it a boolean value?


<?php
$values = array(2, "2", 2.5, "2.5", null, true);
foreach ($values as $value) {
    echo "is_bool(";
    var_export($value);
    echo ") = ";
    var_dump(is_bool($value));
}
?>

The code above generates the following result.