Headers already sent 🐘 PHP

Warning: Cannot modify header information - headers already sent

You called header(), setcookie() or session_start() after output had already been sent to the browser.

Seen on: PHP WordPress

Meaning

HTTP headers must come before the body. Any output — even a single space before <?php, a BOM, or an echoed warning — flushes headers. The message tells you exactly where output started: “output started at /path/file.php:12”.

Common causes

  • Whitespace or blank lines before <?php or after a closing ?>
  • UTF-8 BOM at the start of a file
  • echo/HTML before header() redirect
  • PHP notices/warnings printed before headers

⚡ Quick fix

  1. Open the file/line in “output started at…” and remove the output
  2. Omit closing ?> in pure-PHP files
  3. Save files as UTF-8 without BOM
  4. Do redirects/cookies before rendering any HTML

Detailed fix by platform

PHP

  1. As a last resort ob_start() at the very top buffers output, but fix the real cause.

How to diagnose

  1. Output start — Which file:line does the warning name?
  2. Encoding — BOM present?
  3. Order — Is header() called after HTML?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.