expression
Use identities
not good:
Simple comparison will convert the string into an integer
$a = '42'; $b = 42; if( $a != $b ) { //这里始终执行不到 }
Comparison $a != $b
returned FALSE
but should return TRUE !
The string '42' is not equal to the integer 42
good:
Checking types and data using identity tests
$a = '42'; $b = 42; if ($a !== $b) { // The expression is verified } The comparison $a !== $b returns TRUE.