问题
It seems really inefficient that in PHP, when an array is assigned by value all of its internal elements are recursively copied to the new variable. Is this what really happens internally?
回答1:
No, the internally array is not deep-copied on assignment. Consider the following snippet:
$a = array(111, 222, 333);
$b = $a;
$b[0] = 999;
If a picture is worth a thousand words, then here is what happens internally when arrays are assigned and then their array elements are modified:
来源:https://stackoverflow.com/questions/28280833/when-you-assign-by-value-an-array-variable-in-php-is-the-array-really-deep-copi