note 84911 added to function.unset
| From: | nox at oreigon dot de | Date: | Tue, 05 Aug 2008 19:24:58 +0000 |
| Subject: | note 84911 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143181@lists.php.net to get a copy of this message | ||
if you try to unset an object, please be careful about references.
Objects will only free their resources and trigger their __destruct method when *all* references are
unsetted.
Even when they are *in* the object... sigh!
<?php
class A {
function __destruct() {
echo "cYa later!!\n";
}
}
$a = new A();
$a -> a = $a;
#unset($a); # Just uncomment, and you'll see
echo "No Message ... hm, what now?\n";
unset($a -> a);
unset($a);
echo "Finally that thing is gone\n";
?>
Of course the object completely dies at the end of the script.
----
Server IP: 69.147.83.197
Probable Submitter: 91.62.49.148
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- https://master.php.net/note/edit/84911
Del: integrated -- https://master.php.net/note/delete/84911/integrated
Del: useless -- https://master.php.net/note/delete/84911/useless
Del: bad code -- https://master.php.net/note/delete/84911/bad+code
Del: spam -- https://master.php.net/note/delete/84911/spam
Del: non-english -- https://master.php.net/note/delete/84911/non-english
Del: in docs -- https://master.php.net/note/delete/84911/in+docs
Del: other reasons-- https://master.php.net/note/delete/84911
Reject -- https://master.php.net/note/reject/84911
Search -- https://master.php.net/manage/user-notes.php