<story><title>PHP: md5(&apos;240610708&apos;) == md5(&apos;QNKCDZO&apos;)</title><url>http://3v4l.org/tT4l8</url></story><parent_chain><item><author>dietrichepp</author><text>I&amp;#x27;m not exactly clear on how PHP == works, but you can see the MD5 for yourself:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    $ echo -n 240610708 | md5sum
    0e462097431906509019562988736854  -
    $ echo -n QNKCDZO | md5sum
    0e830400451993494058024219903391  -
    $ echo -n aabg7XSs | md5sum
    0e087386482136013740957780965295  -
&lt;/code&gt;&lt;/pre&gt;
All of them start with 0e, which makes me think that they&amp;#x27;re being parsed as floats and getting converted to 0.0.  This is why &amp;quot;magic&amp;quot; operators like == in PHP and JavaScript never should have existed in the first place.  Operators like == should be, by default, extremely boring.  PHP&amp;#x27;s just happens to be a bit more magical even than JavaScript&amp;#x27;s.</text></item></parent_chain><comment><author>DoubleMalt</author><text>Once I wrote a little PHP application to manage a clan in a browser game. I used an MD5 hash as session id that I checked with 
   if(session_id)&lt;p&gt;When users started reporting that their logins would sometimes not work at the first time, I found out that strings that start with zero are coerced to 0 and then interpreted as false.&lt;p&gt;Never used PHP for anything important since.</text></comment>
<story><title>PHP: md5(&apos;240610708&apos;) == md5(&apos;QNKCDZO&apos;)</title><url>http://3v4l.org/tT4l8</url></story><parent_chain><item><author>dietrichepp</author><text>I&amp;#x27;m not exactly clear on how PHP == works, but you can see the MD5 for yourself:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    $ echo -n 240610708 | md5sum
    0e462097431906509019562988736854  -
    $ echo -n QNKCDZO | md5sum
    0e830400451993494058024219903391  -
    $ echo -n aabg7XSs | md5sum
    0e087386482136013740957780965295  -
&lt;/code&gt;&lt;/pre&gt;
All of them start with 0e, which makes me think that they&amp;#x27;re being parsed as floats and getting converted to 0.0.  This is why &amp;quot;magic&amp;quot; operators like == in PHP and JavaScript never should have existed in the first place.  Operators like == should be, by default, extremely boring.  PHP&amp;#x27;s just happens to be a bit more magical even than JavaScript&amp;#x27;s.</text></item></parent_chain><comment><author>lars</author><text>This, combined with the fact that you can increment strings gives some &amp;#x27;interesting&amp;#x27; results:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    $a = &amp;quot;2d9&amp;quot;; 
    $a++; 
    echo $a . &amp;quot;\n&amp;quot;; 
    $a++; 
    echo $a . &amp;quot;\n&amp;quot;; 
&lt;/code&gt;&lt;/pre&gt;
Output&lt;p&gt;&lt;pre&gt;&lt;code&gt;    2e0
    3&lt;/code&gt;&lt;/pre&gt;</text></comment>