This error message gets triggered when anything is sent before you send HTTP headers (with setcookie
or header
). Common reasons for outputting something before the HTTP headers are:
Accidental whitespace, often at the beginning or end of files, like this:
<?php
// Note the space before "<?php"
?>
To avoid this, simply leave out the closing ?>
- it's not required anyways.
3F 3C
. You can safely remove the BOM EF BB BF
from the start of files.echo
, printf
, readfile
, passthru
, code before <?
etc.display_errors
php.ini property is set. Instead of crashing on a programmer mistake, php silently fixes the error and emits a warning. While you can modify the display_errors
or error_reporting configurations, you should rather fix the problem.$_POST['input']
without using empty
or isset
to test whether the input is set), or using an undefined constant instead of a string literal (as in $_POST[input]
, note the missing quotes).Turning on output buffering should make the problem go away; all output after the call to ob_start
is buffered in memory until you release the buffer, e.g. with ob_end_flush
.
However, while output buffering avoids the issues, you should really determine why your application outputs an HTTP body before the HTTP header. That'd be like taking a phone call and discussing your day and the weather before telling the caller that he's got the wrong number.