ID: 30264 Updated by: [EMAIL PROTECTED] Reported By: mpn at illearth dot net -Status: Open +Status: Feedback Bug Type: Output Control Operating System: Win NT(2K) PHP Version: 4.3.9 New Comment:
I can't reproduce your problem. headers_sent() reports correct value in any situation when running your reproduce script. Previous Comments: ------------------------------------------------------------------------ [2004-10-01 05:12:14] mpn at illearth dot net OK, yes output buffering in the ini is set to the default of 4096. So based on what I am seeing (i.e. ouput in the browser), the buffer is being flushed at 4096 bytes, however the value of headers_sent() is still FALSE, even though it appears the buffer has been flushed at least once, if not several times at the point of the exit. Now what is even more quirky is I can clean and shutdown all the buffers prior to the exit in the error handler and I will not get any screen output in the browser. When doing this the value of headers_sent() is still FALSE. This suggests the buffer has not been flushed at it's default flush point. So two senarios exist here: 1) Do NOT clean and shutdown the buffers and I get output in the browser up to the point of the fatal error exit in the error handler. The value of headers_sent() is FALSE. 2) Clean and shutdown all buffers at the point of the fatal error exit in the error handler, no output to the browser has been sent. The value of headers_sent() is FALSE. In the first senario, the value of headers_sent() should be TRUE since I am seeing intended output in the browser. ------------------------------------------------------------------------ [2004-10-01 05:12:14] mpn at illearth dot net OK, yes output buffering in the ini is set to the default of 4096. So based on what I am seeing (i.e. ouput in the browser), the buffer is being flushed at 4096 bytes, however the value of headers_sent() is still FALSE, even though it appears the buffer has been flushed at least once, if not several times at the point of the exit. Now what is even more quirky is I can clean and shutdown all the buffers prior to the exit in the error handler and I will not get any screen output in the browser. When doing this the value of headers_sent() is still FALSE. This suggests the buffer has not been flushed at it's default flush point. So two senarios exist here: 1) Do NOT clean and shutdown the buffers and I get output in the browser up to the point of the fatal error exit in the error handler. The value of headers_sent() is FALSE. 2) Clean and shutdown all buffers at the point of the fatal error exit in the error handler, no output to the browser has been sent. The value of headers_sent() is FALSE. In the first senario, the value of headers_sent() should be TRUE since I am seeing intended output in the browser. ------------------------------------------------------------------------ [2004-09-30 22:45:44] [EMAIL PROTECTED] If you are using default config you probably have output buffering enabled, which makes PHP buffer output data in 4096 chunks. ------------------------------------------------------------------------ [2004-09-30 16:11:04] mpn at illearth dot net Let me put this into the context of the problem I am having. I am using a custom error handler. At the error threshold where script execution will exit I need to check if headers had been sent in order to determine if output compression needs to be enabled and buffers cleaned/shutoff. Apparently stacking compressed output buffers (even if they have been "cleaned" of content) is restricted since it destroys the output (i.e. the browser shows compressed output). This may be a bug in itself since according to documentation output buffers are stackable with no mention of any restrictions. So let's take it step by step. 1) script excution starts 2) get support includes 3) start output (i.e. headers are set, ouput buffering started, output content printed/echoed). 4) Trigger a fatal exit error. 5) var_dump the return of headers_sent() and exit prior to sending any error messages to the browser or flushing any buffers. At this point the normal expected output, up to the point of the error, has been sent to the browser, however the value of headers_sent() is still FALSE even though I am looking at the expected output in the browser, with the variable dump value at the bottom of that output where the exit occurs. ------------------------------------------------------------------------ [2004-09-30 06:34:24] mpn at illearth dot net "When you use compression the entire page is buffered in memory, until end of the request." The second test example does not use any compression and I stated in the first example that the returned result was the same regards of where output buffering was started, or for that matter even used. I agree it is not a "bug" in that it's returning what it should based on the behavior of the test code. However in the second test example, no buffering of output is taking place and yet the function is still returning false. Remove the buffering from test code example 1 and you get the same result. This is NOT the behavior I would expect according to documentation. In previous versions of PHP the second test example (and the first for that matter) would generate a warning, in at least vs. 4.3.9 it is not. I understand the reasons for not sending headers until the script is complete (buffering or not), but I don't understand the need for a function that will always return false until a time when it is too late to send anymore headers, and why the documentation is clearly stating the opposite is true. So why even bother testing if headers have been sent? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/30264 -- Edit this bug report at http://bugs.php.net/?id=30264&edit=1