When will __destruct not be called in PHP?

The __destruct will not be called:

  • If exit is called in another destructor
  • Depending on the PHP Version: if exit is called in a shutdown function registered with register_shutdown_function
  • If there is a fatal error somewhere in the code
  • If another destructor throws an exception
  • If you try to handle an exception in a destructor (PHP >= 5.3.0)

Guess that’s all I can think of right now

& What Pascal MARTIN said. That’s the first step of debugging that.

Leave a Comment