#15025 [Opn->Ver]: Copy of array is affected by reference
| From: | iliaa@php.net | Date: | Wed, 18 Sep 2002 01:50:59 +0000 |
| Subject: | #15025 [Opn->Ver]: Copy of array is affected by reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-19583@lists.php.net to get a copy of this message | ||
ID: 15025
Updated by: iliaa@php.net
Reported By: jimmy@harlindong.com
-Status: Open
+Status: Verified
Bug Type: Scripting Engine problem
Operating System: FreeBSD, Linux
-PHP Version: 4.1.1
+PHP Version: 4.3.0-dev
New Comment:
updating version.
Previous Comments:
------------------------------------------------------------------------
[2002-09-17 13:31:26] kylam@superapple.org
Verified with 4.2.3 on Windows 2000 too.
------------------------------------------------------------------------
[2002-01-13 22:32:27] jimmy@harlindong.com
$c should not have been affected by the assignment to $b because $c
should only be a copy to $a.
What happened is the first echo shows 5 and after assignment to $b, the
content of $c changes to 1 when it should stay as 5.
------------------------------------------------------------------------
[2002-01-13 22:18:55] jimmy@harlindong.com
You can guess / see from this simple script:
$a = array(5);
$b =& $a[0];
$c = $a;
echo $c[0];
$b = 1;
echo $c[0];
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15025&edit=1