News for hackers. Stuff that matters.
Re:What's new in PHP 8? by tyingq on Thursday August 13, 2020 @10:38PM (#24152595)
"If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number"

And a string that doesn't look like a number at all is converted to 0.

No, I'm not condoning this madness.

Re:What's new in PHP 8? by coldtea on Thursday August 13, 2020 @10:49PM (#24152669)
Well, in C you can cast any random set of bytes to an int, so there's that...
Re:What's new in PHP 8? by overgard on Thursday August 13, 2020 @11:09PM (#24152823)
Sure but in C you usually do that explicitly, on purpose. Here it's almost certainly not what you wanted or expected.. Also, C is 20-30 years older and I don't think I've ever read anyone really compliment its type system in any way other than saying it's simple.
Re:What's new in PHP 8? by andreygrehov on Friday August 14, 2020 @02:58AM (#24154669)
If one doesn't know the language, they can write shitty code, regardless whether it's C or PHP. Any decent PHP programmer knows about the `===` operator that doesn't do any type juggling.
Re:What's new in PHP 8? by tyingq on Friday August 14, 2020 @08:14AM (#24156857)
This problem isnt really fixed with === per se. Converting strings to numbers is a common need, and the weird type conversation here is broken (and being fixed) for more than just implicit conversions in comparisons.

The PHP team is calling it "saner numeric strings"...seems to indicate they agree.