Cannot modify header information - headers already sent

From Joomla! Documentation

Revision as of 03:29, 24 July 2008 by Chris Davenport (Talk | contribs)

In the HTTP protocol a server response consists of a group of headers followed by a body, separated by a single blank line (i.e. a line containing only a carriage-return). This warning message is produced by PHP if a program attempts to send an additional HTTP header after the separator (and hence all the headers) has already been sent.

By far the most common cause of this problem is that one or more PHP files contains characters (usually a space or an empty line) outside of the <?php and ?> tags. To fix the problem you should examine the PHP file indicated in the warning message and remove any blank characters at the beginning and end of the file. Some text editors, including some online file managers, are prone to automatically adding extraneous line-ending characters at the ends of files, particularly when not configured to do otherwise.

Remove the closing ?> tag at the end of your PHP files. It actually serves no useful purpose as the PHP interpreter knows that end-of-file means end-of-PHP too. Removing it means that any extra blank characters added by your editor will have no effect on the output generated and so will not prevent additional HTTP headers from being sent.