How to exit a PHP script without calling the destructor?
问题 Working with an MVC framework and the controller renders the page in the destructor. I am downloading a file through php, so at the end of the action the script should end. How to end the script without calling the destructor? Is there a better solution? exit and die call the destructor. 回答1: As David said: you'll need to call exit() inside a destructor to stop it. If however you just want to halt the visual output caused by these destructors but not any other side-effects (file closing,