ID:               22655
 Updated by:       [EMAIL PROTECTED]
 Reported By:      stanislav at shramko dot com
-Status:           Open
+Status:           Feedback
-Bug Type:         Class/Object related
+Bug Type:         Scripting Engine problem
 Operating System: WinXP
 PHP Version:      4.3.0
 New Comment:

And what did you expect the output to be?



Previous Comments:
------------------------------------------------------------------------

[2003-03-12 02:15:55] stanislav at shramko dot com

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 this bug report at http://bugs.php.net/?id=22655&edit=1

Reply via email to