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: