Log in / create account | Login with OpenID
DocForge
An Open Wiki For Software Developers

PHP/is bool

From DocForge

< PHP

is_bool is a PHP function used to determine if a variable is a boolean data type.

boolean is_bool($variable)

$variable is any type of variable to be evaluated. The type of value the variable holds is inspected and no additional evaluation is performed. So a string, for example, containing the word "true" will not be considered a boolean.

is_bool returns true if the variable is a boolean and false otherwise.

Examples:

$boolean = true;
$integer = 1;
$string = 'true';
 
is_bool($boolean);  // Returns true
is_bool($integer);  // Returns false
is_bool($string);  // Returns false

See Also [edit]