|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54894 array copy semantics with references inside arrays
Submitted: 2011-05-20 15:46 UTC Modified: 2012-11-12 09:15 UTC
Avg. Score:3.7 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mlvl dot jr at gmail dot com Assigned:
Status: No Feedback Package: Documentation problem
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: mlvl dot jr at gmail dot com
New email:
PHP Version: OS:


 [2011-05-20 15:46 UTC] mlvl dot jr at gmail dot com
There probably should be an explicit reference to this:

"While not being strictly an assignment by reference, expressions created with the language construct array() can also behave as such by prefixing & to the array element to add.

The page also explains your why your first code behaves like it does:

    Note, however, that references inside arrays are potentially dangerous. Doing a normal (not by reference) assignment with a reference on the right side does not turn the left side into a reference, but references inside arrays are preserved in these normal assignments. This also applies to function calls where the array is passed by value." (taken from

at the documentation page for 'array':

[coming from]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-20 00:21 UTC]
I'm not sure what the documentation problem is that you're reporting here. Could 
you please elaborate a bit more on what the bug is?
 [2012-11-12 09:15 UTC]
-Status: Open +Status: No Feedback
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Aug 06 02:01:24 2020 UTC