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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC