PHP is_bool() function

In this chapter you will learn:

  1. Description for PHP is_bool() function
  2. Syntax for PHP is_bool() function
  3. Parameter for PHP is_bool() function
  4. Return value for PHP is_bool() function
  5. Example - Is it a boolean value

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   j  av  a  2  s  . c  om*/
$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.

Next chapter...

What you will learn in the next chapter:

  1. Description for PHP is_float() function
  2. Syntax for PHP is_float() function
  3. Parameter for PHP is_float() function
  4. Return value for PHP is_float() function
  5. Example - Is it a float type variable
Home » PHP Tutorial » PHP Data Type Functions
PHP boolval() function
PHP floatval() function
PHP gettype() function
PHP intval() function
PHP is_array(value) function
PHP is_bool() function
PHP is_float() function
PHP is_int() function
PHP is_null() function
PHP is_numeric() function
PHP is_object() function
PHP is_resource() function
PHP is_string() function
PHP isset() function
PHP settype() function
PHP strval() function