ID: 43009 Comment by: codeslinger at compsalot dot com Reported By: hamdi at rawasy dot com Status: Open Bug Type: Feature/Change Request Operating System: Irrelevant PHP Version: 4.4.7 New Comment:
apologies for the poor grammar, I should have proof-read more carefully before hitting submit. Previous Comments: ------------------------------------------------------------------------ [2007-12-19 21:08:31] codeslinger at compsalot dot com I suspect your problem is not a bug at all, but is the result of not deciphering an error message that is somewhat mis-leading. What the error message says is "headers have already been sent". What you appears to be complaining about is that you have not in fact sent any headers. What you probably don't realize is that any text at all which is seen to be part of the web page, is considered to create a situation of "headers already sent". The issue is not actually that the headers have been sent, the issue is that the headers MUST proceed any and all text. The usual cause of this situation is when the php tag is not the actual start of the document. if there is even a single space character in front of the tag it will cause this problem. Also any blank lines after the end of the closing php tag can cause this problem. And be sure to check all of your include files. Blank lines at the end of include files drive me totally nuts until I figured out what was going on. Any character at all, including blank lines, which is outside of the php code brackets is considered to be part of the web page itself. In order to use php to send headers, you CAN'T send any other character at all to the web page. The work-around, for sloppy editing/coding is to turn on output buffering, see the manual. With output buffering enabled, php holds anything being sent, and it is able to insert headers in front of already sent text. But this is really the wrong solution, the right solution is to fix your code. The requirement that headers MUST be sent first is defined by the HTTP protocol itself and can not be changed. ------------------------------------------------------------------------ [2007-10-17 17:41:35] hamdi at rawasy dot com Description: ------------ Referring to my previous report that holds ID 42992 http://bugs.php.net/bug.php?id=42992 Yes, PHP is not responsible about virtual() behavior. But I think that it's holding the full responsibility against headers_sent() behavior and I'm asking to fix headers_sent() not virtual(), as it says that headers was already sent while it wasn't, you could send any headers after that and no problems happens (there is no buffer controllers). So, is it still apache problem? Also the filename & line number returned by headers_sent() indicates that headers wasn't sent! and that is stupid behavior Summary You should return true from headers_sent() only when filename & line number are set, otherwise return false. I repeat, this bug is PHP problem located at headers_sent() function! Not anything else. I think that your job here is to fix those bugs not throwing blame at others. So, do your job please! Reproduce code: --------------- <?php virtual("empty.php"); // An empty file var_dump(headers_sent($file, $line), $file, $line); ?> Expected result: ---------------- bool(false) string(0) "" int(0) Actual result: -------------- bool(true) string(0) "" int(0) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43009&edit=1