Destroying a class object
View Single Post
05-16-2009, 01:19 PM
Join Date: Feb 2009
Location: New York
Originally Posted by
Quick question about best practice:
When i create an object i use the standard contructor method. Is there an equivalent for destroying an object? If so what is it? If not, what is best practice - should i be destroying objects when i have finished with them?
You can use the __destruct() construct. The only difference with having one in your class and not having one is that if you don't have one, PHP will destroy your object at the end of the executed script.
As long as there are no more references to the object it will get destroyed.
View Public Profile
Send a private message to allworknoplay
Find More Posts by allworknoplay