PHP数组对象对比机制
$a = [1,2]; $b = [1,'2']; var_dump($a == $b); // true var_dump($a === $b); // false $c = ['ab'=>'ab',1,2]; $d = ['ab'=>'ab',1,2]; var_dump($c == $d); // true var_dump($c === $d); // true $e = ['ab'=>'ab',1,2,['b'=>'b']]; $f = ['ab'=>'ab',1,2,['b'=>'b']]; var_dump($e == $f); // true var_dump($e === $f); // true $g = ['ab'=>['c'=>'c','d'=>['e'=>'e']],1,2,['b'=>'b']]; $h = ['ab'=>['c'=>'c','d'=>['e'=>'e']],1,2,['b'=>'b']]; var_dump($g == $h); // true var_dump($g === $h); // true $m = new static(); $n = new static(); var_dump($m == $n); // true var_dump($m === $n); // false exit;
原创文章请随便转载。愿和大家分享,并且一起进步。-- 江 coder