If that's true, can you please explain me why the result of the following
code
shows 2 instances and not one? Please help.
<?
class CTest {
var $v;
function CTest(&$reg) {
$reg= &$this;
}
function ®() {
return $this;
}
}
$obj0;
$obj1= new CTest($obj0);
$obj2= &$obj1->reg();
$obj0->v= 'a';
$obj1->v= 'b';
$obj2->v= 'c';
printf ("<br>should be equal: %s %s %s<br>\n", $obj0->v, $obj1->v,
$obj2->v);
// obj0 is single, obj1 and obj2 are the same
?>
The result is "a c c". For me it should be "c c c".
I don't see any assingment or what ever, where I didn't specify by
reference.
Where is here the shallow copy?
If all 3 variable would contain unique instances I would understand again -
PHP would not allow references to classes - but obj1 and obj2 behavious like
expected.
that´s currently a bug/shortcoming I think...
--
o----------0-¬---------O-·---¬----o---®-----o o O ° .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ °
·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ °
o © ° . ·
| psychedelic experience | gott@kiffen.de | O ° o °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·