Search code examples
phphttp-headers

PHP headers already sent


Getting the following error:

"Warning: Cannot modify header information - headers already sent by (output started at..."

for the following line:

echo '<center>Current Time is '. gmdate("H:i A") . ' GMT (Greenwich Mean Time or UTC)<br />';

If I comment it out it just throws up the error at the next echo statement. Thoughts on why PHP hates my echo statements so much?

Here is my include toward the bottom of the HTML:

<div id="saveCanForm" width="100%">
<?php include('savereport.php'); ?>
</div>

Solution

  • It's not the echo statements that are the problem. It looks like you have a header call somewhere later in the file, but you can't send headers once you output any text at all. You could either move the headers to the beginning of the script or alternatively use output buffering.