php
$a = array(1); $b =& $a[0]; //注释这条语句最后输出2,1$c = $a;$c[0]++;echo $c[0].$a[0]; // 输出 2,2 注释第二条语句,输出 2,1 。
Reply content:
php
$a = array(1); $b =& $a[0]; //注释这条语句最后输出2,1$c = $a;$c[0]++;echo $c[0].$a[0]; // 输出 2,2 注释第二条语句,输出 2,1 。
http://php.net/manual/en/language.references.whatdo.php
Note, however, that references inside arrays is potentially dangerous. Doing a normal (not by reference) assignment with a reference in the right side does not turn the left side into a referen CE, but references inside arrays is preserved in these normal assignments. This also applies to function calls where the array was passed by value.
In an array of assignments, if there is a reference to the data on the right, the corresponding element of the new array to which the value is assigned is also a reference, so changing the value of $c[0] will also change the value of $a[0].