• PHP Video Tutorials

PHP - is_bool() Function


Advertisements

Definition and Usage

The function is_bool() checks whether the variable is boolean or not.

Syntax

bool is_bool ( mixed $value )

Parameters

Sr.No Parameter & Description
1

value

The variable being evaluated.*mixed: mixed indicates that a parameter may accept multiple (but not necessarily all) types

Return Values

This function returns true if the variable is boolean, else false.

Dependencies

PHP 4 and above

Example

Following example demonstrates use of is_bool() function −

<?php
   $bool1 = true;
   $bool2 = false;
   $bool3 = 0;
   $bool4 = 1;

   echo "bool1 is ".(is_bool($bool1)?'boolean':'not boolean')."<br>";
   echo "bool2 is ".(is_bool($bool2)?'boolean':'not boolean')."<br>";
   echo "bool3 is ".(is_bool($bool3)?'boolean':'not boolean')."<br>";
   echo "bool4 is ".(is_bool($bool4)?'boolean':'not boolean')."<br>";
?>

Output

This will produce following result −

bool1 is boolean
bool2 is boolean
bool3 is not boolean
bool4 is not boolean
php_variable_handling_functions.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements