Cannot modify header information – headers already sent

Update: To identify files that have a problem, I wrote a script. Checkout this blog post.

how often do you see this message?. I was furious and agitated for last two hours. I knew that I have solved this problem before, but didn’t remember either the cause or the solution. Not to reinvent the wheel again, I am documenting it right now, for myself and for others.

There are many possible things that can cause this error. However, the most common thing, atleast in my case, that causes this error is having some spaces after the closing PHP tag i.e. “?>”. This often occurs when you copy and paste the code. To solve it make sure there are no other characters after you PHP closing tag. Delete any trailing spaces.

Hopefully you will find this helpful.

 

Advertisements

About Ritesh Agrawal

I am a applied researcher who enjoys anything related to statistics, large data analysis, data mining, machine learning and data visualization.
This entry was posted in PHP. Bookmark the permalink.

3 Responses to Cannot modify header information – headers already sent

  1. Anonymous says:

    Thank you. 🙂

  2. Zi says:

    Thank you so much!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s