PHP 4.0 Bug #7515: very weird, magic, invisible referencing

From: Date: Sat, 28 Oct 2000 14:25:28 +0000
Subject: PHP 4.0 Bug #7515: very weird, magic, invisible referencing
Groups: php.dev 
Request: Send a blank email to php-dev+get-36259@lists.php.net to get a copy of this message
From: waldschrott@php.net Operating system: linux + win2k PHP version: 4.0 Latest CVS (28/10/2000) PHP Bug Type: Scripting Engine problem Bug description: very weird, magic, invisible referencing This code is pretty self-explanatory... Uncommenting the noticed (*[0]) line, causes the object contained ('root') in the instance of 'obj' to be referenced to whatever, function test() uses a copy $o_copy but reference-counting fails and the contained object 'root' is somehow referenced to the original object in the global scope. After having uncommented *[0] try to uncomment *[1] what should break the reference again, that made me assuming this all is caused by reference counting... <?php class obj { function method() {} } function test($o_copy) { //$o_copy->root=&$o_copy->root; // *[1] $o_copy->root->set_in_copied_o=TRUE; var_dump($o_copy);?><BR><?php } $o->root=new obj(); //$o->root->method(); // *[0] uncomment this line and weirdness starts var_dump($o);?><BR><?php test($o); var_dump($o); ?> -- Edit Bug report at: http://bugs.php.net/?id=7515&edit=1

« previous php.dev (#36259) next »