PHP is_bool() function PHP

PHP is_bool() function  

PHP is_bool() function

PHP is_bool() function

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

Syntax

  1. 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

  1. <?php  
  2.     $x=false;  
  3.     echo is_bool($x);  
  4. ?>  

Output:

PHP Variable Handling is_bool() function

Example 2

  1. <?php  
  2.     $y=false;  
  3.     if (is_bool($y))  
  4.     echo 'This is a boolean type.';  
  5.     else  
  6.     echo 'This is not a boolean type.';  
  7. ?>  

Output:

PHP Variable Handling is_bool() function 

Download free E-book of PHP


#askProgrammers
Learn Programming for Free


Join Programmers Community on Telegram


Talk with Experienced Programmers


Just drop a message, we will solve your queries