Translations:Developers/Object oriented programming in PHP/Objects/13/en

Destructors can be implemented to clean up before an object is actually deleted, which happens when the script ends or if there's no variable pointing to the object anymore when the garbage collector is running. If there's a __destruct method, it's executed before the object will be deleted, even if the script is terminated with.