4 ms·
Even PHP finds null==“null” to be false.
by rgj 6y ago
Even PHP finds null==“null” to be false.
- hunter2_ 6y agoAnd at least you get to strongly compare by adding an extra = (e.g., ===, !==). I just wish the extra character (i.e., the not-as-default versions) weakened instead, like a tilde. But yes, all strings are truthy. Except an empty string! And maybe some little-used nullish characters? Doubtful, but...
- zerocrates 6y ago> But yes, all strings are truthy. Except an empty string! And maybe some little-used nullish characters? Doubtful, but... Or "0"
- timw4mail 6y agoBut not in PHP 8
- zerocrates 6y agoThey changed a lot of the weirder string conversion stuff in PHP 8, but I'm pretty sure "0" is still falsy.
- hunter2_ 6y agohttp://sandbox.onlinephpfunctions.com/code/d6df91536669985a6502c2aeb2362722005e608d http://sandbox.onlinephpfunctions.com/code/d6df91536669985a6... Set it to PHP 8 and click "Execute code," then set it to PHP 7 and Execute again. They give the same result, which is that "0" is falsy in both versions.