php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43009 headers_sent() is PHP responsibility not Apache! do your job please
Submitted: 2007-10-17 17:41 UTC Modified: 2009-12-22 14:19 UTC
Votes:3
Avg. Score:2.3 ± 1.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: hamdi at rawasy dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.4.7 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
26 - 13 = ?
Subscribe to this entry?

 
 [2007-10-17 17:41 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-19 21:08 UTC] 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-12-19 21:18 UTC] codeslinger at compsalot dot com
apologies for the poor grammar, I should have proof-read more carefully before hitting submit.
 [2008-01-24 21:03 UTC] codeslinger at compsalot dot com
I just now got around to reading the docs on "virtual" which your example program is using.

This bug is totally bogus.  The docs make it very clear what the behavior of "virtual" is.  This behavior is by design.

My previous comments about probable causes of "headers already sent" are valid, they just don't apply to your program example.
 [2008-05-27 17:11 UTC] hamdisahloul at hotmail dot com
If you think this is a bugus issue, then at least the output should be something like this:

bool(true)
string(0) "/path/to/empty.php"
int(0)

or 

bool(false)
string(0) ""
int(0)

but not the actual result:

bool(true)
string(0) ""
int(0)


how could headers_sent() acts stupid so it says the headers already sent, but don't indicate the file & line???
 [2009-12-22 14:19 UTC] jani@php.net
The output is fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 12:01:29 2024 UTC