PHP Error - Warning: Cannot modify header information - headers already sent by …
Monday, February 4th, 2008The Problem:
When you load up the PHP script you just created, you get the following error message:
“Warning: Cannot modify header information - headers already sent by …”
Which is then followed by a file location and line number where the output started, and the file and line number where the error occured (the function call where the header was trying to be sent).
The functions that send HTTP headers that can cause this problem are header() and setcookie().
The Explanation:
This problem occurs when you are trying to send HTTP header information AFTER output to the browser has already been started. The most common occurrence of this error is when you have some code that looks something like the following:
(more…)