ID:               43009
 Comment by:       hamdisahloul at hotmail 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:

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???


Previous Comments:
------------------------------------------------------------------------

[2008-01-24 21:03:02] 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.

------------------------------------------------------------------------

[2007-12-19 21:18:07] codeslinger at compsalot dot com

apologies for the poor grammar, I should have proof-read more carefully
before hitting submit.

------------------------------------------------------------------------

[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

Reply via email to