php.net |  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
Votes:3
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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 http://www.php.net/manual/en/language.references.whatdo.php)

at the documentation page for 'array':
http://php.net/manual/en/language.types.array.php

[coming from http://stackoverflow.com/questions/6072444/php-array-copy-semantics-what-it-does-when-members-are-references-and-where-is/]


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-20 00:21 UTC] googleguy@php.net
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] aharvey@php.net
-Status: Open +Status: No Feedback
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC