When is __destruct called in PHP?
__destruct method is called either during the shutdown sequence (i.e. end of execution of a script), or when there are no references to an object.
Remember that if you put a
destruct() method in a subclass, you must call
parent::destruct() if you want the parent's destruct method to execute (assuming there is one).
The method will be called even if exit() is called. However, if exit() is called from within a destructor, then no further destructors will be called.
Note: completely unrelated to Array Destructuring.