ID: 23705
Updated by: [EMAIL PROTECTED]
Reported By: joachim at lous dot org
-Status: Open
+Status: Verified
-Bug Type: Scripting Engine problem
+Bug Type: Zend Engine 2 problem
-Operating System: Windows 2000
+Operating System: *
-PHP Version: 4.3.1
+PHP Version: 5.0.0b2-dev, 4.3.3RC2-dev
New Comment:
Same result with ZE2.
Previous Comments:
------------------------------------------------------------------------
[2003-05-19 14:59:47] joachim at lous dot org
It doesn't seem to be possible to replace a passed object references
with a different one.
I expected the following code to print "5":
class a{
var $val;
function a($val){ $this->val = $val;}
}
function replace(&$src, &$dest){
$dest =& $src;
}
$src = new a(2);
$dest = new a(1);
replace($src,$dest);
$src->val=5;
echo $dest->val;
In stead it prints "1".
Changing the '=&' to '=', it prints '2', as expected.
Surely this must be a bug? If not, is there really no way to get the
reference across?
I need this for building trees: passing the current node pointer, have
the function change the tree and make the ref point to a new current
node. I can work around it by returning the new reference in stead, but
that only works for one ref.
Using binary installer from website.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23705&edit=1