Introduction
In this article I will explain Boolean data types in PHP. Boolean is the simplest type. A Boolean expression is a true type value. It is used in control structures like for testing portions of an if statement. It can be either TRUE or FALSE.
Types of the Boolean Value
| Data Type | True Value | False Value |
| Integer | All the non-zero values | 0 |
| Floating Point | All the non-zero values | 0.0 |
| Null | Never | Always |
| Array | If it is contains only one elements | Does not contains any elements |
| String | All other string | Empty string ()"" The Zero string ()"0" |
| Object | Always | Never |
| Resource | Always | Never |
Example
<?php
$height=100;
$width=50;
if ($width == 0)
{
echo "The width needs to be a non-zero number";
}
?>
In the above example, it would be false and, therefore, the echo statement will never execute.
<?php
$height=100;
$width=50;
if ($width)
{



Join the conversation! Your thoughts help the community grow.