ID:               23228
 User updated by:  prof_moriarty at veryfast dot biz
 Reported By:      prof_moriarty at veryfast dot biz
-Status:           Bogus
+Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Win 98
 PHP Version:      4.3.0
 New Comment:

Let's see if i'm getting the gist of this:
I send data to the browser, followed by a header, and headers_sent will
return true.
Or something like that.

But what i want to be able to do is:

Check to see if any data has been sent to the browser BEFORE sending
headers...
because the headers that I want to send are based on the content of the
page.

i.e.:
Script to generate a .png image. Most browsers will only show a .png
when the thing has the correct headers 
   Header("Content-type: image/png");

But let's say something goes wrong with the script, and an error is
reported.
If i then proceed to tell the browser the thing is an image, i get a
big white screen (because the result is actually a fairly messed up
image, with text in it (which can be viewed by looking at the
page-source))...

so my function would do something like:

if(proposed_function()){
   Header("Content-type: image/png"); //no errors
} else {
   //error, so tell the browser we're playing with text, not an image
   Header("Content-type: HTML");
}


I hope that better explains it... And if such an ability does excist
(without having to use output control), then i'm sorry for wasting your
time... :)


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

[2003-04-22 14:18:20] [EMAIL PROTECTED]

headers_sent() will do what you want.

I know you're asking for a function which tells you if NON-header
infomation has been sent (as stated in your second paragraph), but the
exact way in which headers are buffered needs to be understood.

headers are never sent until content is forced out to the browser. 
Therefore headers_sent() will not return TRUE until real content has
reached the browser.

If output buffering is on, real content (such as: print "foo!\n"; ) can
be in the buffer (but not sent to the browser) without having sent
headers (and so headers_sent() will return FALSE).  When that buffer is
flushed to the browser however, the headers are flushed as well (making
that function return TRUE).

If output buffering is not on, individual headers can be sent, but
headers_sent() will not yet return TRUE because header content is
psuedo-buffered until content is sent.  Again, once content is output
the headers are flushed and headers_sent() will begin returning TRUE.

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

[2003-04-15 15:18:25] prof_moriarty at veryfast dot biz

A feature request.
I've been reading through the manual for 4.3.something, and i can't
find a function to do this, so i figured i'd suggest it.

Basically a function that will determine if any data has actually been
sent to the browser, and return TRUE or FALSE depending on the result.
This function would check to see if ANY data had been sent to the
browser (cookies and headers excluded), including error messages!


I realise there are the "output control functions", however in the case
i have, they don't really help me. Partially because i'm not sure if
errors are actually buffered or sent straight through ignoring them.

Also there is the $php_errormsg variable, but that's only related to
the 'track errors' configuration which defaults to off (meaning it's
never going to be on on a host).

Thanx
Jonathan

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


-- 
Edit this bug report at http://bugs.php.net/?id=23228&edit=1

Reply via email to