Tuesday, June 16, 2009

Getting Rid of the Headers Already Sent Error in PHP

The "Headers Already Sent" error is incredibly common, usually looks like this :
Warning: Cannot modify header information - headers already sent by (output started at /home/myaccount/public_html/globals.php:42) in /home/myaccount/public_html/index.php on line 198

To get rid of this, you can try one of the following tips :
  • replace the header('location:page.php') with <script>window.location='page.php'</script>
  • remove all blank spaces before the phrase header('location:page.php')
    Blank spaces includes html tags, press of enter, or just a single press of spacebar.
  • remove all white space before or after the opening and closing PHP tags.

No comments:

Post a Comment