What does “Warning: Cannot Modify Header Information – Headers Already Sent” mean?

Posted OnDec 4, 2013     CategoryTroubleshooting     CommentsNo comment

In this article we’ll be looking at how to resolve the error “Warning: Cannot Modify Header Information – Headers Already Sent”

To fix this, you’ll need FTP/SFTP/SSH access to your server.

What does “Warning: Cannot Modify Header Information – Headers Already Sent” mean?

If you’re getting this error, you have most likely (albeit accidentally) added some whitespace to a PHP file that WordPress is not expecting. The error message should define which file this occurs in though it is generally in wp-config.php.

Step 1) Read the error message to deduce what file the whitespace is in.

Step 2) Navigate to and open the offending file.

Step 3) Ensure the first characters of the file are >?php and the final characters are ?< and there’s absolutely nothing before or after.

Step 4) Check that there are no unnecessary code blocks, such as

Correct:

<?php
  function awesome(){
    echo $variable;
  }
?>

Incorrect:

<?php
  function notAwesome(){
    echo $variable1;
  }
?>

<?php
  function notAwesome2(){
    echo $variable44;
  }
?>

This should remedy the problem. If not you should recover the file from a backup or upload a clean version of it, though beware that this may result in data loss.

Leave a Reply

Your email address will not be published. Required fields are marked *

Send this to friend