note 54402 deleted from function.unset by didou
| From: | didou@php.net | Date: | Sun, 07 Jan 2007 01:52:58 +0000 |
| Subject: | note 54402 deleted from function.unset by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121364@lists.php.net to get a copy of this message | ||
Note Submitter: seka04 at student dot bth dot se
----
As of PHP 5 unset doesn't seem to work as a means to make an object self destruct, consider the
following code:
class A
{
function Delete()
{
unset($this);
}
}
In PHP 4 this way worked perfectly, in PHP 5 I haven't found any way to get the above code to
work. The use for this is in for example a XML tree structure, I have a XML class which interface I
used like this before:
$n = &$XMLObeject->doc->FindNodeById( $someID );
$n->Delete();
Very convinient for deleting nodes in the tree, doesn't work anymore though. unset($n)
doesn't even work, I think it has to do with the fact that the nodes parent keeps 2 references
to this data and that PHP 5 somehow changed how that works. Using $n = NULL do work, even if I think
it's very ugly compared to the other 2 sollutions.