From: stanislav at shramko dot com Operating system: WinXP PHP version: 4.3.0 PHP Bug Type: Class/Object related Bug description: problems with unset
I was very discouraged about the behavior of unset() function with variables which are contained in objects in the same time. Also I'm slightly mad about references to NULL and so on. <?php // two test classes class a { var $a = null; function a( &$b ) { $this->a = &$b; } } class b { var $b = 5; } // ---------- the main part ------------ // alas, I need to use destructors $b = &new b(); $a = &new a( $b ); var_dump( $a ); // checking the object's state $b->b = 3; // changing it var_dump( $a ); // Note that value was changed... unset( $b ); // what are we waiting for? var_dump( $a ); // but the object's field wasn't affected $b = null; var_dump( $a ); // there's no way to destroy this blamed property echo "------------------------------------------------------------\n"; // but in case if we will try to assign a null value to this field whilst // the object is in it's initial state, we're getting another results $b = &new b(); $a = &new a( $b ); var_dump( $a ); $b->b = 3; var_dump( $a ); // Note that value was changed... $b = null; var_dump( $a ); // I see, it's a great way to dispose a field of an object :) // this reference to NULL looks pretty well, isn't it? :) ?> I've lost the sence of the whole situation at this point. Regards, Stanislav. -- Edit bug report at http://bugs.php.net/?id=22655&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22655&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22655&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22655&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22655&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22655&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22655&r=support Expected behavior: http://bugs.php.net/fix.php?id=22655&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22655&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22655&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22655&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22655&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22655&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22655&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22655&r=gnused