PHP is_bool() function

Description

is_bool(value) returns true if value is a Boolean.

Syntax

PHP is_bool() function has the following syntax.

is_bool(value)

Parameter

  • value is the variable being type checked.

Return

Returns true if value is a Boolean.

Example

Is it a boolean value?


<?php//from w ww  .  j  a v a2s .co m
$values = array(2, "2", 2.5, "2.5", null, true);
foreach ($values as $value) {
    echo "is_bool(";
    var_export($value);
    echo ") = ";
    var_dump(is_bool($value));
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions