4 ms·
So: 0 == 'x' results in bool(true) Does anyone know the technical reasons for this?
by Deestan 17y ago
So:
0 == 'x'
results in
bool(true)
Does anyone know the technical reasons for this?
- rbanffy 17y agodaeken explained it quite well. From his post: "As explained under 'read more', it's because 'test' will be cast to a number for comparison. Since 'test' isn't a number, it becomes 0, which is equivalent."
- mlLK 17y agoThese tables illustrate how complicated type checking in PHP really is: http://www.php.net/manual/en/types.comparisons.php http://www.php.net/manual/en/types.comparisons.php