PHP is_bool() Function

PHP 可用的函数PHP Available Functions

is_bool()The function is used to detect whether a variable is boolean.

PHP Version Requirements: PHP 4, PHP 5, PHP 7

Syntax

bool is_bool ( mixed $var )

Parameter Description:

  • $var: The variable to be checked.

Return Value

Returns TRUE if var is boolean.

Example

Example

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

The output result is:

变量 a 是布尔型

PHP 可用的函数PHP Available Functions

Other Extensions