In PHP, when other types of variables are converted to Boolean, the following values are considered FALSE:
A Boolean value of FALSE itself;
Integer value 0 (0);
Floating-point value 0.0 (0);
An empty string (""), and a string ("0");
An array that does not include any elements;
Objects that do not include any member variables (PHP 4.0 only applies);
Special type NULL (including variables that have not yet been set);
A SimpleXML object generated from an XML document without any tags (tags);
All other values are considered TRUE (including any resources).
Note:-1 and other non-0 values (either positive or negative) are considered to be true!
Var_dump ((BOOL) ""); BOOL (FALSE)
Var_dump ((bool) 1); BOOL (TRUE)
Var_dump ((BOOL)-2); BOOL (TRUE)
Var_dump ((bool) "foo"); BOOL (TRUE)
Var_dump ((bool) 2.3e5); BOOL (TRUE)
Var_dump ((BOOL) array (12)); BOOL (TRUE)
Var_dump ((bool) array ()); BOOL (FALSE)
Var_dump ((BOOL) "false"); BOOL (TRUE)
?>
http://www.bkjia.com/PHPjc/486078.html www.bkjia.com true http://www.bkjia.com/PHPjc/486078.html techarticle in PHP, when other type variables are converted to Boolean, the following values are considered false: the Boolean value false itself, the integer value 0 (0), the Float value 0.0 (0), the empty string (""), and the character ...