Topic awaiting preservation: php "cannot add header information" |
|
---|---|
Author | Thread |
Obsessive-Compulsive (I) Inmate From: chicago, IL usa |
posted 01-15-2003 11:17
hi. any clue why the following... |
Paranoid (IV) Inmate From: Milwaukee |
posted 01-15-2003 11:29
Take a look at the code referenced by the error messages. Somewhere, you've got a bug that's echoing output to the client before your location header goes off. Posting the code a few lines above and below the error references might help us understand what's going on. |
Obsessive-Compulsive (I) Inmate From: chicago, IL usa |
posted 01-15-2003 12:02
Perfect Thunder: Thank you. It came to me while I was reading about the header function on php.net... my php script was unnecessarily inside <html> tags. I'm such a newbie. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 01-15-2003 13:44
sorry, not 100% sure what you mean... |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
posted 01-15-2003 14:10
The poster has demanded we remove all his contributions, less he takes legal action. |
Maniac (V) Inmate From: Florida |
posted 01-17-2003 04:10
Use output buffering with ob_start() and ob_end_flush(). code: <?php ob_start();
|
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 01-17-2003 11:26
the drawback of outputbuffering should be mentioned as well: There is no output till your script reaches output_end_flush() (or output_flush()). That means, if you have a long running script, the user might see nothing of it. |
Maniac (V) Inmate From: Florida |
posted 01-17-2003 14:41
Output buffers are stackable, that is, you may call ob_start() while another ob_start() is active. So technically you do not have to wait the entire length of a script to output data. Just make sure that you call ob_end_flush() the appropriate number of times. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order. I should also mention ob_get_contents(). Instead of sending output as-is, you can process it, manipulate it, and even cancel it as you see fit. Example: you could write the contents of an output buffer to a file before flushing it. |