4 ms·
null == 0 is true. null === 0 is false. false == 0 is true. false === 0 is false. null == false is true. null === false is false. null < -1 is true.
by xellisx 6y ago
null == 0 is true.
null === 0 is false.
false == 0 is true.
false === 0 is false.
null == false is true.
null === false is false.
null < -1 is true.
- jraph 6y agoLike in JavaScript, just don't use ==. It's broken but you don't have to use it. In C you can write i[t] instead of t[i], but don't do it. I guess it's true for many languages. These funny features don't prevent you from writing good code, especially if you enforce some coding styles that will catch any unintended use of these features. Blame PHP for what you can't do with it, or for things you don't like but are forced to do. For instance I like PHP but I cannot type things the way I'd like. It's getting better though. I don't like the inconsistencies in the function names of the standard library but the functions are often straightforward and very simple to use. And, above all, the doc is good. These aspects mean I don't waste time figuring out how to do simple things because of a complex interface involving many classes, despite the inconsistencies. I also don't like the dollar notation for variables but that's a matter of taste, nor the syntax for namespaces, nor the implicit declaration of variables (like in Python by the way).
- SwiftyBug 6y ago> In C you can write i[t] instead of t[i], but don't do it. I had to check this myself. I'm astonished.
- ChrisSD 6y agoC array access syntax is just syntactic sugar for pointer arithmetic. The array decays to a pointer so `t[i]` is interpreted as: *(t + i) So you can see how swapping that around to `i[t]` is effectively the same operation: *(i + t)
- throwaway8748 6y agoare you sure null < -1 is true? If it's the case what happens to 0 < -1?
- zozbot234 6y agoWell, -1 is just 0x…FFFFF, right? So any number is lesser than -1. I rest my case.
- xellisx 6y agoTo test all cases and make sure there there isn't any weird cases (Run on PHP 7.2): <?php if (null > -1) { echo "null > -1\n"; } if (null < -1) { echo "null < -1\n"; } if (null == -1) { echo "null == -1\n"; } if (null === -1) { echo "null === -1\n"; } if (0 < -1) { echo "0 < -1\n"; } if (0 > -1) { echo "0 > -1\n"; } if (0 == -1) { echo "0 == -1\n"; } if (0 === -1) { echo "0 === -1\n"; } results: null < -1 0 > -1