explicitly destroy Objects in PHP5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


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.

Any Ideas?

Best Regards
Thomas Ilsche

Re: explicitly destroy Objects in PHP5

On 18 Apr 2005 07:01:01 -0700, google@zulan.net (Thomas Ilsche) wrote:

Quoted text here. Click to load it

Remove all references to the object.

Quoted text here. Click to load it

If you were to explicitly destroy the object than these multiple
variables would reference a destroyed object -- that would not be a
good thing.  

The best option is still to remove all the references.

Quoted text here. Click to load it

Use a flag to prevent __destruct from doing anything more the second
time it's called.  What is going on in your destructor anyway?

Quoted text here. Click to load it

C++ doesn't have garbage collection which is why it has delete.  PHP
has garbage collection so delete isn't needed.  

Site Timeline