Can I trust PHP __destruct() method to be called?
garbage-collection, php
Solution
The destructor will be called when the all references are freed, or when the script terminates. I assume this means when the script terminates properly. I would say that critical exceptions would not guarantee the destructor to be called.
The PHP documentation is a little bit thin, but it does say that Exceptions in the destructor will cause issues.
Problem
In PHP5, is the __destruct() method guaranteed to be called for each object instance? Can exceptions in the program prevent this from happening?