1. All equals not only the value of the variable is the same, but the same type is required. The following example
<? PHP $a=10; $b= ' ten '; Var_dump ($a= =$b,$a= = =$b);? >
The output is bool (TRUE) bool (false), which shows the difference between = = and = = =.
2. For an all-equal example, see the following code
<? php $str = ' Hyper ' ; $s = ' h ' ; if (strpos ( $str , $s ) ==false $s . ' does not exist in '. $str . ' ";} else { $ s . ' exist in '. $str . ' ";} ?
The output is (H does not exist in hyper), which is strange, H is clearly in the hyper, but the output is not. Careful observation, found that H is the first letter of hyper, so the output of the Strpos () function is 0,0 and false = = operation, the result 0 is cast to Boolean false, of course, to prevent this situation, we use = = =, so not only the comparison value, but also the comparison type, There will be no mistakes. After correction, the following
<? PHP $str= ' Hyper '; $s= ' h '; if (strpos($str,$s) = = =false) { echo$s. ' does not exist in '. $str. ' ';} Else { echo$s. ' exist in '. $str. ' ';}? >
The output is (H exists in hyper).
PHP Learning notes-all equals