Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- explicitly destroy Objects in PHP5
- Thomas Ilsche
April 18, 2005, 12:01 pm
rate this thread
how do I "explicitly destroy" an Object in PHP5 to make sure the
destructor is called an the object destroyed?
unset is not an option because there are multiple variables containing
the object handle.
Waiting for the end of the script is aswell a bad option because the
order in which the destructores are called does matter.
So what else could be done to "explicitly destroy" the object?
If i simply call __destruct it would be called twice, bad aswell.
Since I have intensively searched the manual I fear there is no C++
like "delete Obj" construct in PHP. I really wonder why this is not
the case since destructors exist and the other OOP features of PHP5
seem really fine.
Re: explicitly destroy Objects in PHP5
On 18 Apr 2005 07:01:01 -0700, email@example.com (Thomas Ilsche) wrote:
Remove all references to the object.
If you were to explicitly destroy the object than these multiple
variables would reference a destroyed object -- that would not be a
The best option is still to remove all the references.
Use a flag to prevent __destruct from doing anything more the second
time it's called. What is going on in your destructor anyway?
C++ doesn't have garbage collection which is why it has delete. PHP
has garbage collection so delete isn't needed.