News for hackers. Stuff that matters.
Re:An Internet of PHP by chx on Saturday September 09, 2023 @04:34AM (#37443356)
> The language is very unplanned, go look at an equality chart for PHP, it makes JavaScript blush as well.

This has been fixed in PHP 8. https://wiki.php.net/rfc/string_to_number_comparison

Re:An Internet of PHP by xigoi on Saturday September 09, 2023 @07:17AM (#37444098)
> make non-strict comparisons more useful and less error prone, by using a number comparison only if the string is actually numeric. Otherwise the number is converted into a string, and a string comparison is performed.

That… makes it even worse.

Re:An Internet of PHP by slim on Saturday September 09, 2023 @12:31PM (#37447189)
why?
Re:An Internet of PHP by xigoi on Saturday September 09, 2023 @12:44PM (#37447333)
Because now the behavior of comparison depends on whether the string looks like a number.
Re:An Internet of PHP by chx on Saturday September 09, 2023 @01:33PM (#37447868)
Arguably 48 == "48" should be true. If this doesn't work for you, stick to ===.
Re:An Internet of PHP by xigoi on Saturday September 09, 2023 @01:37PM (#37447927)
Thank you, I'll stick to languages where you can't just compare numbers and strings without an explicit conversion.

Also, should 48 == "48.0" be true? How about "048", "48.", "0x30", " 48 ", "48foo", "3*16", "XLVIII", "forty-eight"?

Re:An Internet of PHP by chx on Sunday September 10, 2023 @06:41AM (#37454605)
Once again: just use ===

If you decide languages based on minutiae like this, I can only pity you.

Re:An Internet of PHP by xigoi on Sunday September 10, 2023 @06:43AM (#37454619)
=== works for equality (if you actually remember to use it), but how about comparison? There's no strict version of <.
Re:An Internet of PHP by chx on Sunday September 10, 2023 @11:39AM (#37456869)
strcmp