PHP is_bool() function

PHP is_bool() function

ᴰᵒᵖᵖᵉˡᵍᵃⁿᵍᵉʳ 多佩尔甘格尔

By using this function, we can check whether the variable is boolean variable or not.

 

Syntax

bool is_bool ( mixed $var )  

 

Parameters

Parameter

Description

Is compulsory

var_name

The variable being evaluated.

compulsory

 

Returns

It return True if var is boolean, False otherwise.

 

Example 1

<?php  
    $x=false;  
    echo is_bool($x);  
?>  

 Output:

You


Example 2

<?php  
    $y=false;  
    if (is_bool($y))  
    echo 'This is a boolean type.';  
    else  
    echo 'This is not a boolean type.';  
?>  

 Output:


Report Page