English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP is_bool() Function Usage and Example

PHP Available Functions

is_bool() The function is used to check if a variable is of boolean type.

PHP Version Requirement: PHP 4, PHP 5, PHP 7

Syntax

bool is_bool ( mixed $var )

Parameter Description:

  • $var: The variable to be checked.

Return Value

If var is boolean, it returns TRUE.

Online Example

<?php
$a = false;
$b = 0;
// Because $a is of boolean type, the result is true
if (is_bool($a)) {
    print "Variable a is of boolean type";
}
// Because $b is not of boolean type, the result is false
if (is_bool($b)) {
    print "Variable b is of boolean type";
}
?>

The output result is:

Variable a is of boolean type

PHP Available Functions