Quote:
Originally Posted by AndrewGSW
Can you show the code where you actually compare the true/false value?
Try with a strict comparison: ===
|
^ This
The problem is that PHP doesn't actually have a boolean, which is inherited from the C code which also doesn't have a boolean. Ultimately, boolean false is 0, and true is !0.
Fortunately, operations can use strict datatyping in PHP. Using identical operators (===) for individual comparisons, and using in_array with strict parameter checking (third parameter), are good options. Searching arrays can also be performed on strict checking. The identical check also performs a check on the zval type on top of the zval value (default is to check only the value).
You'll get to know the identical operator in PHP. Many functions especially string and array functions return false on failure. Since PHP arrays (and implicitly the strings since they are char arrays) are all 0 based, you need to use identical checking for false to see if it failed or not. Common operations for these are strpos and array_search.