php8.5
Home/ Manual/ var / functions/ is_bool

is_bool

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Finds out whether a variable is a boolean

Description

is_bool(mixed $value): bool

Finds whether the given variable is a boolean.

Parameters

value

The variable being evaluated.

Return Values

Returns true if value is a bool, false otherwise.

Examples

is_bool() examples

php
<?php
$a = false;
$b = 0;

// Since $a is a boolean, it will return true
if (is_bool($a) === true) {
    echo "Yes, this is a boolean\n";
}

// Since $b is not a boolean, it will return false
if (is_bool($b) === false) {
    echo "No, this is not a boolean\n";
}
?>

See Also

Source: reference/var/functions/is-bool.xml · from the official PHP manual (php/doc-en)