Knowledgebase

Warning: Cannot modify header information Print

  • php, troubleshooting, wordpress, themes, errors, redirects, guide, howto
  • 0

Output was sent before headers.

WHAT IT MEANS

PHP tried to set a header after content had already been sent. Headers must come first.

THE MESSAGE NAMES TWO FILES

The file attempting to set the header, and the file that already produced output.

The second one is where the problem is.

THE USUAL CAUSE

Whitespace before the opening PHP tag or after the closing tag in a file.

A blank line at the end of wp-config.php or a theme's functions.php is the classic case.

THE FIX

Open the file named as producing output. Remove any space or blank line before the first opening tag.

Remove the closing tag entirely at the end of a pure PHP file. It is not required, and it prevents trailing whitespace causing this.

OTHER CAUSES

An echo or print statement before a redirect A file saved with a byte order mark, which some editors add invisibly An error or warning printed before the header

IF IT APPEARED AFTER AN EDIT

Suspect the file you edited. Check its very beginning and very end.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot