note 28480 added to language.oop.constructor
| From: | ianyates at rack1 dot php dot net | Date: | Tue, 14 Jan 2003 15:32:58 +0000 |
| Subject: | note 28480 added to language.oop.constructor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42128@lists.php.net to get a copy of this message | ||
Although not very good practice, I had a use for it.
In PHP you can destroy an object using unset(object instance) from outside of the object, but I
needed to destroy the object from within.
After much experimentation, I simply set $this to null within a function inside the object.
This had the desired affect of removing the object from memory.
Note that unsetting $this does not have the same affect.
It would be better practice to set a variable within the object when it needed to be destroyed and
then pick this up externally to mark the object as destroyed.
Hope this helps someone.
--
http://www.php.net/manual/en/language.oop.constructor.php
http://master.php.net/manage/user-notes.php?action=edit+28480
http://master.php.net/manage/user-notes.php?action=delete+28480
http://master.php.net/manage/user-notes.php?action=reject+28480