Home About Us Services Portfolio Articles Reference Contact

PHP Warning: Cannot modify header information

Spotlight on PHP Have you ever come across the following warning when working with PHP  files?

Warning: Cannot modify header information – headers already sent by (output started at /index.php:1) in /file.php on line …

Solution One: the case of unnecessary white space.

The problem may be caused by what is commonly referred to as the “white space problem”. Some text editors tend to add white spaces or empty lines at the beginning or end of a PHP file when the file is edited. This added space interferes with the page loading properly in the browser. Remove the white spaces at the beginning and/or end of the file and the problem should be solved.

Solution Two – The case of the mystery symbol:

The answer to solving the mystery behind this dilemma may be the invisible symbol:



This symbol is a BOM or Byte Order Mark of the Unicode Standard. It is invoked when a PHP file is created or edited in a text editor such as Notepad and saved. The BOM’s UTF-8 is misinterpreted as ISO 8859/1 instead of UTF-8. This causes the BOM to be interpreted as literal text. You will not see this symbol as visible text in some text editors while editing.

To solve the problem, use a text editor like CSE HTML Validator. In the screen shot below, you will see the “” to the left of the first line of text in the file. Simply delete the “”, save the file with the editor and upload. The PHP Warning problem should be solved.

Text editor

Did you find this post helpful? Please let us know!

© R & R Web Design LLC is a Michigan web design company specializing in custom web design, natural ethical search engine optimization and webmaster solutions.

Tags: ,

Leave a Reply