Re: Restore output buffer in case of exceptions
| From: | Evert | Rooftop | Date: | Sun, 18 Nov 2007 00:38:46 +0000 |
| Subject: | Re: Restore output buffer in case of exceptions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33228@lists.php.net to get a copy of this message | ||
Mehmet Yavuz Selim Soyturk wrote:
Hello, I'm sorry if that's the wrong list. I am neither a PHP nor a webscripting guy so I'm sorry if this does not make sense. I just thought that it could be useful. PHP 5 supports exception handling. When an exception occurs, PHP does stack unwinding so that it restores the state of the script. But an important state of the script does not get restored: the output. Would it not be a good idea if PHP also did some sort of output buffer unwinding? Generally I make sure that the parts of my code that start an output buffer are also responsible for closing the output buffer.. so something like this wouldn't be uncommon in my code..ob_start(); try { do_something(); } catch (Exception $e) { ob_end_clean(); throw $e; } $data = ob_get_clean();