Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your example would return true if just the first character was alike. And no, that's not how it works. PHP converts strings that look like numbers into floats and compares afterwards.


WHY?

"Hey, this very precise literal has a passing resemblance to another data type, so let's convert it to that, but since it's got too many digits and resembles another data type at this point, let's just throw away some of the data, make the conversion, THEN perform the equality comparison." Yeah, that makes sense. FAIL.


I'm not defending PHP. I'm not saying it makes sense. I'm just saying that's what's happening.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: