Warning: Cannot modify header information - headers already sent

Posted on : Mon, 20th Apr 15 07:22 am UTC
100+ votes

This is a most common type of error's that once may get in PHP pages with header functions, lets see reasons that could cause this issues and how to fix it.

  1. Output Statements :

    You might be having echo, printf output statements before the header that would cause this issue.

  2. Unwanted Blank Spaces :

    There should be no blank lines or whitepaces spaces before or after the <php and ?> tags.

  3. File Format :

    Make sure that the file format is UTF-8.

  4. Include files :

    You might be having a include() to include a php page that may contain header redirects.

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +