PHP Function Is_Bool
PHP supports a lot of data types including boolean values. However, sometimes it might be difficult to figure out whether a variable is of the boolean type or not. The php function is_bool helps you to find out this information. The is_bool function evaluates a value and returns True if the variable is a boolean type, or False if not. This function is useful when you want to make sure that a variable is of the boolean data type before doing any operation on it or when you want to handle booleans and non-booleans in a specific way.
The is_bool() function works similar to the other "is_type" functions like is_int(), is_float(), is_string() etc. The only difference between these functions is that it checks whether a given input variable is of the boolean type.
Boolean values are the simplest of all data types and can be either TRUE or FALSE. They are used in conditional statements like if, while, for and switch etc. Booleans are the most commonly used control structure in all programming languages. The if() statement checks if the output of the variables is equal to a particular number, then it executes the commands written in that section of the loop. If the output is not equal to a certain number, it executes the commands written in the else portion of the loop. In the above example, no comparison operator is used because PHP automatically converts the variable value 50 to its Boolean equivalent of true and executes the statements written in if().