|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2003-04-15 15:18 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 16:00:01 2025 UTC | 
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... :)