Bug #55723 [Opn->Bgs]: Array of references return copies of elements instead of references
| From: | laruence@php.net | Date: | Mon, 19 Sep 2011 04:58:31 +0000 |
| Subject: | Bug #55723 [Opn->Bgs]: Array of references return copies of elements instead of references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163671@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55723&edit=1
ID: 55723
Updated by: laruence@php.net
Reported by: exsystemchina at gmail dot com
Summary: Array of references return copies of elements
instead of references
-Status: Open
+Status: Bogus
Type: Bug
Package: Arrays related
Operating System: Windows XP Pro SP 3
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
see blow:
<?php
$Item = array ('foo' => 'bar');
$Array = array (&$Item);
$rItem = & $Array[0];
$rItem['foo'] = 'foobar';
echo $Item['foo'];
Previous Comments:
------------------------------------------------------------------------
[2011-09-19 02:50:37] exsystemchina at gmail dot com
[Sorry, Grammar Error.]When trying to get [an] element of reference inside an
array, php always returns a
copy of that variable being referred. See the comment of Test Script.
------------------------------------------------------------------------
[2011-09-19 02:46:35] exsystemchina at gmail dot com
Description:
------------
When trying to get a element of reference inside an array, php always returns a
copy of that variable being referred. See the comment of Test Script.
Test script:
---------------
<?php
$Item = array ('foo' => 'bar');
$Array = array (&$Item);
$rItem = $Array[0]; //$rItem is expected to be a reference, but it doesn't.
$rItem['foo'] = 'foobar';
echo $Item['foo'];
Expected result:
----------------
foobar
Actual result:
--------------
bar
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55723&edit=1