ID:               31884
 Updated by:       [EMAIL PROTECTED]
 Reported By:      camka at email dot ee
-Status:           Open
+Status:           Wont fix
 Bug Type:         Zend Engine 2 problem
 Operating System: Linux
 PHP Version:      5.0.3
 New Comment:

$this is a special variable and is processed differently than other
variables.

Creating references to it simply won't work the way you're expecting it
to.


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

[2005-02-08 14:47:13] camka at email dot ee

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31884&edit=1

Reply via email to