A question to be discussed in the group today, record it.
The origin of the problem is
Var_dump (MD5 (' 240610708 ') = = MD5 (' Qnkcdzo ')); True
A string of two md5, compared with the comparison operator (= =), is actually equal.
Output a value of two values, respectively:
MD5 (' 240610708 ')//0e462097431906509019562988736854
MD5 (' Qnkcdzo ')//0e830400451993494058024219903391
Seeing the result, the first feeling is intval, so 0 = = 0 Returns True,
Later, I was reminded that this was not the case.
PHP comparison operators:
http://php.net/manual/zh/language.operators.comparison.php
Example:
If you compare a number and a string or compare strings that involve numeric content, the strings are converted to numeric values and compared to numeric values. This rule also applies to switch statements. The type conversion is not performed when compared with = = = or!==, because the type and the value are compared at this time.
Truevar_dump ("1" = = "01"); 1 = = 1-truevar_dump ("ten" = = "1e1"); Ten = = Truevar_dump (+ = "1e2"); + = Trueswitch ("a") {case 0: echo "0"; Break;case "a"://Never reached because "a" is already matched with 0 echo "a"; break;}? >
In other words, this equality is not because two strings are intval, and become 0=0
But is numerically 0e4xxx = = 0e8xxx, that is, scientific notation, 0*10 of the N-square, that is, 0.0000 and 0.00000000
So there will be an equal result.
The above describes the php-weak type of small traps, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.