|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-08 16:17 UTC] pollita@php.net
[2005-02-09 00:00 UTC] camka at email dot ee
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 22:00:02 2025 UTC |
Description: ------------ When setting reference to $this object, using "=&" operator in a class method doesn't seem to work as expected (or my understanding is completely wrong). When unsetting object outside of the class methods - link breaks and won't unset the referenced objects. Reproduce code: --------------- <?php class uu { public $ref; public function set_me_as_ref(uu &$whom) { $whom->ref = &$this; } } $obj1 = new uu(); $obj2 = new uu(); $obj2->set_me_as_ref($obj1); $obj2 = null; // this won't unset $obj1->ref, but unsets only $obj2 object // $obj1->ref = null; // this won't unset the $obj2 object, but unsets only $obj1->ref echo '<pre>'; var_dump($obj1, $obj2); ?> Expected result: ---------------- $obj1->ref is supposed to be null $obje2 - is supposed to be null Actual result: -------------- $obj1->ref => living object $obj2 => null