PHP is_bool ()

PHP

Syntax :
 boolean is_bool ($variable_name)  $variable_name : the variable we want to check. < / pre> return value : this is a boolean function, so it returns TRUE when $variable_name is a boolean value, otherwise FALSE.Example 1 :  < tr>    
// php code $variable_name1 = false; $variable_name2 = 32;  
// $variable_name1 is a boolean value, gives TRUE if ( is_bool ( $variable_name1 )) echo " Variable is a boolean. " ; else echo ` Variable is not a boolean. ` ;  
// $variable_name2 is a boolean value, returns FALSE if ( is_bool ( $variable_name2 )) echo ` 32 is a boolean. ` ; else echo ` 32 is not a boolean.` ; ?>
Exit :
Variable is a boolean. 32 is not a boolean.
Example 2 :
// PHP code function square ( $num ) { return ( is_bool ( $num )); } echo square (TRUE). " " ; // outputs ` 1 & # 39 ;. echo square (FALSE). "" ; // outputs ` 1 & # 39 ;. echo square (56). "" ; // nothing is returned. 
?>
Exit :
1 1
Link : http: // php.net/manual/en/function.is-bool.php



Get Solution for free from DataCamp guru