"Headers already sent" in PHP — What It Means and How to Fix It

What the PHP error "Headers already sent" means and how to fix it.

Published October 31, 2026

"Headers already sent" occurs when code tries to set an HTTP header after output has already started being sent to the browser.

Key points

  • Often caused by whitespace or output before an opening <?php tag, or an earlier echo statement before a later header() call
More PHP articles