note 54402 added to function.unset
| From: | seka04 at student dot bth dot se | Date: | Sun, 03 Jul 2005 08:39:38 +0000 |
| Subject: | note 54402 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91343@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54402
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54402&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54402&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54402&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54402&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54402&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54402&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54402&report=yes
Search -- http://master.php.net/manage/user-notes.php