php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37225 tangled references
Submitted: 2006-04-27 16:07 UTC Modified: 2006-08-24 15:08 UTC
From: max at hightech dot lv Assigned: dmitry (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.2 OS: ALL
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: max at hightech dot lv
New email:
PHP Version: OS:

 

 [2006-04-27 16:07 UTC] max at hightech dot lv
Description:
------------
looks like after copy reference to some variable, source-variable start to be reference it self. Is it correct? In result we can't make copy array, if some of it element was used as reference.

Reproduce code:
---------------
$arr = array("TEXT" => "test");
$tmp =& $arr["TEXT"];
$zz = $arr;
$zz["TEXT"] = 1;
var_dump($arr);


Expected result:
----------------
array(1) { ["TEXT"]=> string(4) "test" }

Actual result:
--------------
array(1) { ["TEXT"]=> &int(1) }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-24 14:56 UTC] tony2001@php.net
Duplicate of #37917.
You're copying and modifying refernces and this is expected.
 [2006-08-24 15:02 UTC] max at hightech dot lv
But why after the second line "$arr" is references? I don't define it as references!
 [2006-08-24 15:08 UTC] max at hightech dot lv
"$a1 =& $a2;
This line means that both $a[0] and $a[1] become references that point to the same value."

I see now. strange... I don't change variable, but it change...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 12:01:32 2024 UTC