note 95773 added to function.ob-end-clean

From: Date: Thu, 21 Jan 2010 12:02:48 +0000
Subject: note 95773 added to function.ob-end-clean
Groups: php.notes 
Request: Send a blank email to php-notes+get-165160@lists.php.net to get a copy of this message
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. ---- Server IP: 92.43.200.200 Probable Submitter: 157.181.166.13 ---- Manual Page -- http://www.php.net/manual/en/function.ob-end-clean.php Edit -- https://master.php.net/note/edit/95773 Del: integrated -- https://master.php.net/note/delete/95773/integrated Del: useless -- https://master.php.net/note/delete/95773/useless Del: bad code -- https://master.php.net/note/delete/95773/bad+code Del: spam -- https://master.php.net/note/delete/95773/spam Del: non-english -- https://master.php.net/note/delete/95773/non-english Del: in docs -- https://master.php.net/note/delete/95773/in+docs Del: other reasons-- https://master.php.net/note/delete/95773 Reject -- https://master.php.net/note/reject/95773 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#165160) next »