I wonder why this code return true instead of false
var_dump(md5('240610708') == md5('QNKCDZO'));
Thanks in advance, any explanation will be appreciated.
I wonder why this code return true instead of false
var_dump(md5('240610708') == md5('QNKCDZO'));
Thanks in advance, any explanation will be appreciated.
Try this instead:
var_dump(md5('240610708') === md5('QNKCDZO'));
Looks, like these md5 hashes, which starts from '0e', are parsed by PHP as a decimal numbers with exponent (see var_dump(100 == "1e2"); // 100 == 100 -> true
from Comparison Operators).
That is why they are interpreted as equals. To avoid this, must use strict comparison.
Update:
And strcmp
gives the correct result, too. If I understand correctly, because there is no conversions in case of strcmp
.