Hacker News new | past | comments | ask | show | jobs | submit login

What's the equivalent of === for < and > in PHP?



Use < and > for numbers and strcmp for strings. A strict type > would be very weird because besides returning TRUE and FALSE it'd need to throw a TypeError, I guess?


>A strict type > would be very weird because besides returning TRUE and FALSE it'd need to throw a TypeError, I guess?

Yes, which would make it behave exactly like probably every language with strong runtime typechecks. Very weird indeed. It's obviously much more preferable that the code sometimes does the wrong thing without warning.

And of course with static typing, it would be extremely weird since the code wouldn't even pass the compiler!


I don't think the snark in this response is super helpful; a simple "Yes, throw a TypeError when the types are incorrect" would have sufficed.


Congratulations for being the last straw. I'm getting out of this site for good.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: