2 ms·
To be clear: it's a matter of correctness, not preference. Using a boolean constant to represent "not a string" when there are legal string values that are equ
by ajross 18y ago
To be clear: it's a matter of correctness, not preference. Using a boolean constant to represent "not a string" when there are legal string values that are equal to that constant is a design bug, that you are working around via the identity operator. I'm happy that PHP has a null; less so that you don't see value in using it where it's required.
- nuclear_eclipse 18y agoWell, my point is: $str = ''; $str == null; #true $str == false; #true null == false; #true So in the case of PHP, it's not a matter of correctness, simply because of how PHP handles type coercion. 'false' and 'null' both have legal string values that can evaluate as equal to them or each other.