Warning: Cannot modify header information - headers already sent
You called header(), setcookie() or session_start() after output had already been sent to the browser.
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
<?phpor after a closing?> - UTF-8 BOM at the start of a file
echo/HTML beforeheader()redirect- PHP notices/warnings printed before headers
⚡ Quick fix
- Open the file/line in “output started at…” and remove the output
- Omit closing
?>in pure-PHP files - Save files as UTF-8 without BOM
- Do redirects/cookies before rendering any HTML
Detailed fix by platform
PHP
- As a last resort
ob_start()at the very top buffers output, but fix the real cause.
How to diagnose
- Output start — Which file:line does the warning name?
- Encoding — BOM present?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026