News for hackers. Stuff that matters.
Re:PHP: md5('240610708') == md5('QNKCDZO') by ams6110 on Monday May 04, 2015 @09:07AM (#9485868)
To be fair, this kind of thing (maybe not exactly this, but type-coercion bugs) can happen in JavaScript, which is all the rage now for "important" stuff.
Re:PHP: md5('240610708') == md5('QNKCDZO') by shuzchen on Monday May 04, 2015 @04:10PM (#9488798)
This is levels worse than what Javascript does though. Most high-level languages have some sort of implicit coercion (even python lets you do truth tests on non-boolean values). The problem here is the programmer isn't confused about types at all. They're comparing two things of the same type: two strings! Nevertheless, given two strings PHP tries to coerce them into ints before carrying out the equality test. Yes, you will have coercion bugs in other languages if you're testing things of different types, but I don't know any other language where a equality test between two things of the same type are automatically coerced into another.
Re:PHP: md5('240610708') == md5('QNKCDZO') by wmil on Monday May 04, 2015 @09:24AM (#9485945)
It can happen in a few languages, but PHP is notably more aggressive in trying to convert to int.

Actually a common way to grief new websites is to try to register '0' as a username. `if (string)` is a common way to check for null, and '0' will often fail.

Re:PHP: md5('240610708') == md5('QNKCDZO') by bcruddy on Monday May 04, 2015 @10:50AM (#9486461)
Yeah but javascript has 'use strict' whereas PHP decided that the easter egg "looks like you're using the wrong language!" was more important than actually allowing a 'use strict' to force === instead of ==.
Re:PHP: md5('240610708') == md5('QNKCDZO') by Silhouette on Monday May 04, 2015 @01:35PM (#9487645)
While that's true, JavaScript is still horribly error-prone because of this. The suggestion that JS would be a much better language if the == operator worked more like === in the first place is very reasonable.
Re:PHP: md5('240610708') == md5('QNKCDZO') by samspot on Wednesday May 06, 2015 @10:34AM (#9498891)
I don't think strict mode affects == vs. === Best bet is to use a linter to catch that.