A common error seen, however rarely known or understood is the "headers already sent" error. Which may look similar to this:
Warning: Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23
To understand why headers must be sent before output it's necessary to look at a typical HTTP response. PHP scripts mainly generate HTML content, but also pass a set of HTTP/CGI headers to the webserver:
HTTP/1.1200 OK Powered-By: PHP/5.3.7Vary:Accept-EncodingContent-Type: text/html; charset=utf-8<html><head><title>PHP page output page</title></head><body><h1>Content</h1> <p>Some more output follows...</p>and<a href="/"><img src=about:note>...
The page/output always follows the headers. PHP is required to pass the headers to the webserver first. It can only do that once. And after the double linebreak it can't ever append to them again.
When PHP receives the first output (
<html>) it will "flush" the collected headers. Afterwards it can send all the output bits it wants. But sending further headers is impossible from then.
As all developmental issues are different, and coded in different ways, this is only a suggestion of a possible solution.
Just because you cannot see anything does not mean that PHP sees the same.
To be sure about the end of the file, do this: