Boolean is the simplest type in PHP. The value can be true or false.
For example:
$ Foo = false;
$ Foo1 = true;
When Echo "is false, the output value is:". $ Foo; // No output value
Echo "<br/> true:". $ foo1; // output 1
The main details are as follows:
When converted to boolean, the following values are considered false:
1. the Boolean value is false.
2. the integer value is 0 (0)
3. The floating point value is a 0.0 (zero) null string and the string "0"
4. arrays that do not contain any elements
5. objects that do not include any member variables (applicable only to PhP 4.0)
6. Special Type null (including unset variables)
7. simplexml object generated from XML documents without any tags
// $ A = 0;
// $ A = 0.0;
$ A = "0 ";
Var_dump (bool) 0 );
Echo "<br/> ";
Var_dump (bool) array ());
If ($ A = false ){
Echo "null 0 is converted to false by default. Success! ";
} Else {
Echo "cannot be converted to false ";
}
Output:
Bool (false)
Bool (false) null 0 is converted to false by default. Success!