The Boolean type is the simplest type in PHP. It can have a value of TRUE or FALSE,
1 is True (true), 0 is False (false)
In Computer science, a Boolean data type, also known as a logical data type, is a primitive type with only two values: Non 0 (usually 1 or-1) and 0 (equivalent Yu Jin and false, respectively).
In some languages, a Boolean data type is defined to represent more than two truth values. For example, the ISO sql:1999 standard defines a SQL Boolean that can store three possible values: True, FALSE, unknown (SQL NULL is treated as an unknown truth value, but only used in Boolean type).
This data type is used in Boolean and other operations, such as with (and, &, *), or (or, |, +), XOR (XOR, Neqv, ^), equivalence (EQV, =, = =), and non (not, ~,!), which are consistent with logical algebra and arithmetic operations.
Such as:
$foo =false; $foo 1=true;echo "is false when the output value is:". $foo; No output value echo "<br/> is true when output value is:". $foo 1; Output 1
Here are the main details:
When converted to Boolean, the following values are considered FALSE:
1, the Boolean value FALSE itself
2, the integer value 0 (0)
3, the floating-point value 0.0 (0) empty string, and the string "0"
4. An array that does not include any elements
5. Objects that do not include any member variables (PHP 4.0 applies only)
6. Special type NULL (including variables not yet set)
7. SimpleXML object generated from an XML document that does not have any tags (tags)
$a =0;//$a =0.0; $a = "0"; Var_dump ((bool) 0); echo "<br/>"; Var_dump ((bool) array ()); if ($a ==false) {echo " Null 0 default conversion to FALSE, success! ";} Else{echo "cannot be converted to false";}
Output:
BOOL (FALSE)
BOOL (FALSE) NULL 0 default conversion to FALSE, success!