|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-03-12 17:15 UTC] sniper@php.net
[2003-03-12 18:54 UTC] stanislav at shramko dot com
[2003-04-23 05:01 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 11:00:01 2025 UTC |
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.