Easy Tutorial
❮ Func String Str Replace Php Coalescing Operator ❯

PHP is_bool() Function

Available PHP Functions

The is_bool() function is used to check if a variable is of boolean type.

PHP version requirements: PHP 4, PHP 5, PHP 7

Syntax

bool is_bool ( mixed $var )

Parameter description:

Return Value

Returns TRUE if var is a boolean.

Example

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

// Since $a is a boolean, the result is true
if (is_bool($a)) {
    print "Variable a is a boolean";
}

// Since $b is not a boolean, the result is false
if (is_bool($b)) {
    print "Variable b is a boolean";
}
?>

Output result:

Variable a is a boolean

Available PHP Functions

❮ Func String Str Replace Php Coalescing Operator ❯