Bar*_*lom 3 php arrays performance
我们都知道
$a1 = array('foo');
$a2 = $a1;
$a2[0] = 'bar';
// now $a1[0] is foo, and $a2[0] is bar. The array is copied
Run Code Online (Sandbox Code Playgroud)
但是,我记得读过但无法通过Googling确认的是,在修改之前,数组在内部不会被复制.
$a1 = array('foo');
$a2 = $a1; // <-- this should make a copy
// but $a1 and $a2 point to the same data internally
$a2[0] = 'bar';
// now $a1[0] is foo, and $a2[0] is bar. The array is really copied
Run Code Online (Sandbox Code Playgroud)
我想知道这是否属实.如果是这样,那就好了.它会在大量传递大数据时提高性能,但无论如何只能从它读取(创建一次之后).