note 71092 added to function.ob-end-clean

From: Date: Sat, 11 Nov 2006 22:04:08 +0000
Subject: note 71092 added to function.ob-end-clean
Groups: php.notes 
Request: Send a blank email to php-notes+get-119615@lists.php.net to get a copy of this message
Keep in mind that mrfritz379's example (#49800) is just an example. You can achieve that example's result in a more efficient manner without using output buffering functions: echo "<p>Search running. Please be patient. . ."; $output = "<p>FileList: </p>\n"; if (is_dir($dir)) { $dh = opendir($dir); while (($fd = readdir($dh)) != false) { echo " ."; $output .= $fd; } } echo "</br>Search Complete!</p>\n"; echo $output; In addition to John Smith's comment (#42939), ob_gzhandler() may still set the HTTP header "Content-Encoding" to "gzip" or "deflate" even if you call ob_end_clean(). This will cause a problem in the following situation: 1. Call ob_gzhandler(). 2. Echo "Some content"; 3. Call ob_end_clean(). 4. Echo "New content"; In the above case, the browser may receive the "Content-Encoding: gzip" HTTP header and attempts to decompress the uncompressed "New content". The browser will fail. In the following situation, this behaviour will go unnoticed: 1. Call ob_gzhandler(). 2. Echo "Some content"; 3. Call ob_end_clean(). 4. Call ob_gzhandler(). 5. Echo "New content"; This is because the second ob_gzhandler() will mask the absence of the first ob_gzhandler(). A solution would be to write a wrapper, like John Smith did, for the ob_gzhandler(). ---- Server IP: 202.157.183.147 Probable Submitter: 219.95.167.71 ---- Manual Page -- http://www.php.net/manual/en/function.ob-end-clean.php Edit -- https://master.php.net/note/edit/71092 Del: integrated -- https://master.php.net/note/delete/71092/integrated Del: useless -- https://master.php.net/note/delete/71092/useless Del: bad code -- https://master.php.net/note/delete/71092/bad+code Del: spam -- https://master.php.net/note/delete/71092/spam Del: non-english -- https://master.php.net/note/delete/71092/non-english Del: in docs -- https://master.php.net/note/delete/71092/in+docs Del: other reasons-- https://master.php.net/note/delete/71092 Reject -- https://master.php.net/note/reject/71092 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119615) next »