1 $a= 0; 2 $b= "0"; 3 $c= ' '; 4 $d=NULL; 5 $e=false;6 7 Echo"5 Variables-Original test Type";8 Var_dump($a);//int 09 Var_dump($b);//string ' 0 'Ten Var_dump($c);//string " One Var_dump($d);//NULL A Var_dump($e);//Boolean false - - Echo"; the Var_dump(Empty($a));//true - Var_dump(Empty($b));//true - Var_dump(Empty($c));//true - Var_dump(Empty($d));//true + Var_dump(Empty($e));//true - + Echo"; A Var_dump(isset($a));//true at Var_dump(isset($b));//true - Var_dump(isset($c));//true - Var_dump(isset($d));//"false" see conclusion one - Var_dump(isset($e));//true - - Echo"; in Var_dump($a==$b);//true - Var_dump($a==$c);//true to Var_dump($a==$d);//true + Var_dump($a==$e);//true!! - the Var_dump($b==$c);//"false" see conclusion two * Var_dump($b==$d);//"false" see conclusion two $ Var_dump($b==$e);//truePanax Notoginseng - Var_dump($c==$d);//true the Var_dump($c==$e);//true + A Echo"; the Var_dump($a===$b);//false + Var_dump($a===$c);//false - Var_dump($a===$d);//false $ Var_dump($a===$e);//false $ - Var_dump($b===$c);//false - Var_dump($b===$d);//false the Var_dump($b===$e);//false - Wuyi Var_dump($c===$d);//false the Var_dump($c===$e);//false
Summary:For
0;
' 0 ' ;
"';
NULL;
false"Five types of empty operations above five variables, all return false strong equals (
===The comparison is false, with strong language results (three equals not only comparing values, but also comparing types) but for (
==), you need to pay attention to the string type, involving the underlying structure and type conversion conclusion one: the understanding of the variable type 1.null is not meant to exist: PHP's underlying zval space (below the structure) does not have its value, and only stores a type flag whose is_null ( So explained empty (null) =true,isset (NULL) =false, Isset (") =true) 2."
0;
' 0 ';
"';
false": These four exist, PHP bottom is open zval space storage, there is value, there is type conclusion two: 1, string
' 0 'With string
"'Not equal, (think about it, understand that the same type compares "1 Length" of the string can be equal to "0 length" of the string) 2, int
0But with string
"' Null equals, (non-homogeneous comparisons, PHP will do type conversions) 3, string
' 0 ' And
NULLunequal, int
0And
null Equal
Article turned from:70217267
PHP 0, NULL, NULL and false the difference "précis-writers"