PHP is_bool() Function

PHP is_callable() Function
PHP is_array() Function

In this article, you will learn how to check if a variable is of boolean type in PHP. The is_bool() function in PHP checks whether a variable is a boolean or not. This function returns true (1) if the variable is a boolean, otherwise, it returns false/nothing.

what is the syntax of the IS_BOOL() function in php?

is_bool(variable);
ParameterDescription
variableRequired. Specifies the variable to check
PHP is_bool() method

examples of the IS_BOOL() function

Example 1. In this example, we check whether a variable is a boolean or not.

<?php
$a = 1;
echo "a is " . is_bool($a) . "<br>";

$b = 0;
echo "b is " . is_bool($b) . "<br>";

$c = true;
echo "c is " . is_bool($c) . "<br>";

$d = false;
echo "d is " . is_bool($d) . "<br>";
?>
PHP is_callable() Function
PHP is_array() Function
en English
X
Scroll to Top