note 95772 deleted from function.ob-end-clean by danbrown

From: Date: Thu, 21 Jan 2010 15:24:59 +0000
Subject: note 95772 deleted from function.ob-end-clean by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165167@lists.php.net to get a copy of this message
Note Submitter: netom at elte dot hu ---- Notice that ob_end_clean() does discard headers. If you would like to clear the output buffer, but not the headers (because you use firephp for example...), than this is the solution: <?php ... $headers = array(); if ( !headers_sent() ) { $headers = apache_response_headers(); } ob_end_clean(); ob_start(); if ( !empty( $headers ) ) { foreach ( $headers as $name => $value ) { header( "$name: $value" ); } } ... ?> I use it in a general exception handler in a web application, where I clear the buffer (but not the debug-info-containing headers), and send a 500 error page with readfile(). Good PHPing, Tamas.

« previous php.notes (#165167) next »