In PHP programming, you can only use TRUE or FALSE to indicate Boolean values. code example

Example 1: true false php

""         -> false
"0"        -> false
"0.0"      -> true
"1"        -> true
"01"       -> true
"abc"      -> true
"true"     -> true
"false"    -> true
"null"     -> true
0          -> false
0.1        -> true
1          -> true
1.1        -> true
-42        -> true
"NAN"      -> true
0          -> false
NAN        -> true
null       -> false
true       -> true
false      -> false
[]         -> false
[""]       -> true
["0"]      -> true
[0]        -> true
[null]     -> true
["a"]      -> true
{}         -> true
{}         -> true
{"t":"s"}  -> true
{"c":null} -> true

Example 2: php is boolean

The is_bool() function 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.

Example 3: php boolean

Booleans can be one of two constants:
true
false
These values are not case sensitive, therefore true is the same as TRUE

booleans are also often used in control structures, either directly or as
a result of an operation. For example:

if ($waterDrankToday > 3.7) {
 echo "Good work staying hydrated!";
 if ($havingABadDay)
   hug();
}
else
  echo "You should drink more water";

Tags:

Php Example