PHP Cannot modify header information

Problem:

Warning: Cannot modify header information – headers already sent by (output started at blah blah blah) in blahblahblah.php on line 90

Cause:
PHP script has output before calling header().

2 ways to get rid of this:

  1. In php.ini, Set output_buffering to On. If no access to php.ini because of using shared hosting, add “PHP_FLAG output_buffering on” into .htaccess file.
  2. Code your PHP using proper way. Put all Database queries in front,have all (self-generated) functions return data only, build you HTML code inside a variable, print that variable at the end of the page.

Leave a Reply