note 28480 deleted from language.oop.constructor by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 18:58:15 +0000 |
| Subject: | note 28480 deleted from language.oop.constructor by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162540@lists.php.net to get a copy of this message | ||
Note Submitter: ianyates at yahoo dot com
----
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.