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;

 

posted @ 2018-12-27 11:48  jiangxiaobo  阅读(215)  评论(0编辑  收藏  举报