将一个阵列指定给下一个阵列时,将生成一个副本。但是因为
$arr[0]
是引用而不是值,是
所以最后,
$arr2[0]
指的是同一件事。
这更多的是关于引用而不是数组。未复制引用值。这也适用于对象。考虑:
$ageRef = 7;
$mike = new stdClass();
$mike->age = &$ageRef; // create a reference
$mike->fruit = 'apple';
$john = clone $mike; // clone, so $mike and $john are distinct objects
$john->age = 17; // the reference will survive the cloning! This will change $mike
$john->fruit = 'orange'; // only $john is affected, since it's a distinct object
echo $mike->age . " | " . $mike->fruit; // 17 | apple
请参阅上的第一个用户说明
this documentation page
this one
.