ID: 22713 User updated by: public at asd-group dot com Reported By: public at asd-group dot com -Status: Feedback +Status: Open Bug Type: HTTP related Operating System: Windows XP PHP Version: 4.3.1 New Comment:
Hmm I did read and follow the notes, and the following sample script is easily extacted from my description. 4.3.2 made no difference. <?php $Html = Array(); // Output buffering callback - just buffers text and returns "" to PHP (telling it to ignore output) function PhpOutputCb ($txt) { global $Html; if ($txt != "") {$Html[] = $txt;} return ""; } // Install output buffering callback, called on each output statement (due to second parameter) // ISSUE: Second parameter should be documented ob_start('PhpOutputCb', 2); $t = "<pre>Before first output statement, headers_sent() = " . (int) headers_sent() . " </pre>\n"; echo "<html>\n". "<head>\n". "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n". "<meta http-equiv=\"Content-Language\" content=\"en-us\">\n". "<title>Bug1</title>\n". "</head>\n". "<body>\n". $t . "\n"; // ISSUE: Why does headers_sent() now return true, even though headers should not have been sent (as no output actually sent) echo "<pre>After first output statement, headers_sent() = " . (int) headers_sent() . " </pre>\n"; echo "</body>\n". "</html>\n"; // QUESTION: If commented-in, this exit() call causes PhpOutputCb to be called with "" text - why ?? //exit(); // Turn off output buffering and physically output text which our callback buffered ob_end_clean(); foreach ($Html as $key => $val) { echo $val; } ?> Previous Comments: ------------------------------------------------------------------------ [2003-03-15 09:46:51] [EMAIL PROTECTED] Did you read the 'How to report' page at all? Did you try the latest stable snapshot from http://snaps.php.net yet? We're about to release 4.3.2 soon, so you really should test it. But most important: Add a short example script which clearly shows the problem. ------------------------------------------------------------------------ [2003-03-14 21:28:01] public at asd-group dot com What information do you want - I can't think of anything else that might be relevant ??? ------------------------------------------------------------------------ [2003-03-14 19:20:39] [EMAIL PROTECTED] Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. ------------------------------------------------------------------------ [2003-03-14 15:21:25] public at asd-group dot com I'm using output buffering with a callback specified in ob_start. I'm also using the second parameter of value 2 (callback gets called each time output occurs in the application, rather than just once when the whole output buffer is flushed). My callback always returns an empty string, telling PHP to ignore the output, however as soon as this happens (ie. first 'echo' or 'print' statement in application) headers_sent starts to return true. However the HTTP headers (and terminating blank line) cant have been sent because my own calls to header() later on (eg. to set cookies) still work. Also, due to this, any code which expects output buffering to be on, and which checks headers_sent() before sending its own headers (after doing HTML output) will break using output buffering this way. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22713&edit=1