Hi!

PHP's == comparison semantics for strings have a peculiar edge-case, where
comparisons of the form "0e123" == "0e456" return true, because they are
interpreted as floating point zero numbers. This is problematic, because
strings of that form are usually not numbers, but hex-encoded hashes or
similar.

This particular argument makes sense, but in more generic sense I feel it leads us to a dangerous path of implying it's ok to use "==" to compare strings, because we'll take care of the corner cases. Which I think is wrong to imply because there are so many corner cases where it still doesn't work and probably never will. I mean, "000" == "0000000" is still true. "010" == "0000010" is still true. "1e23" == "001e023" is still true. Nobody who applies == to strings and expects it to work out as stri g comparison is doing the right thing. If you apply == to hex-encoded hashes, that code is fubar, and fixing one particular corner case won't rescue it. So I wonder if fixing one particular corner case while leaving many others in would do much.

--
Stas Malyshev
smalys...@gmail.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to