In the past it was said that non 0 is true, but var_dump ((bool) array ()); is also false. How exactly do you judge ture or False in PHP?
------Solution--------------------
Non-0 non-NULL is True
------Solution--------------------
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!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.