ID: 49816 Updated by: sjo...@php.net Reported By: paul at wcclan dot net -Status: Open +Status: Feedback Bug Type: Output Control Operating System: FreeBSD 7.2-RELEASE-p4 PHP Version: 5.2.11 New Comment:
Thank you for bug report. The garbage data you see in the browser is the correct page, but compressed. The data is probably automatically compressed by Apache or PHP, without setting the correct headers. Because the headers are not set, the browser does not uncompress the page. Please check your server settings and confirm this is the problem. There may still be a bug here, in that flush() breaks gzip compression. In that case we need some more information on how the compression is configured. Previous Comments: ------------------------------------------------------------------------ [2009-10-08 20:06:52] paul at wcclan dot net Description: ------------ Looping through the output of a process opened with popen while using flush return "garbage" in the browser. Using telnet the intended output can be seen in (likely corrupted) chuncked encoding. Commenting out the flush() in below code fixes the problem. Reproduce code: --------------- <? $handle = popen("whois php.net", "r"); if($handle) { while(!feof($handle)) { $buffer = fgets($handle); echo $buffer . "<br />\r\n"; flush(); } pclose($handle); } ?> Expected result: ---------------- the output of the command whois php.net Actual result: -------------- seemingly random garbage in browser. Above script available through: http://ipv6.wcclan.net/test.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49816&edit=1