PHP is_bool() function

This function is used to check whether the variable datatype is boolean or not.

Syntax

is_bool(variable);

variable is the required parameter. It returns TRUE if variable is a boolean, FALSE otherwise.

Example

<?php
    $var1 = 'true';
    $var2 = 18;
    if(is_bool($var1)) {
        echo 'True is a boolean value';
    }
    if(is_bool($var2)) {
        echo '18 is a boolean value';
    }
?>

Output of the above code -

True is a boolean value



Related PHP Functions

PHP array_reverse() function
PHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function




Read more articles


General Knowledge



Learn Popular Language