Why you should Turn off Output buffering in php when developing code for others…
A few times now I have developed code for my clients, and when I send it to them, they get an error dealing with output already being sent when something attempts to send a header… You know the classic:
Warning: Cannot modify header information – headers already sent by (output started at /home/a/public_html/wp-admin/includes/plugin.php:1721) in /home/a/public_html/wp-includes/pluggable.php on line 934
This is caused by output having already been sent to the browser, and the headers have to go before the output. Php is smart enough to clear the output buffer if possible before sending headers… So if the output buffer hasn’t been sent to the browser yet because output buffering is enabled php will clear the buffer, and send the header. But if output buffering is disabled, you get an error… And something won’t work right…
So, open up your php.ini file and set output_buffering = Off.
Cheers!
Joey
you need to fix your code to make sure you dont send headers arbitrarily. this is a sign that there is a problem with your design. there should be no reason to send headers once you have already sent them and then sent content. you need to figure out why you are sending headers again. thnks for the writeup
Exactly. If you don’t turn off output buffering, this problem is hidden. So you turn it off so that this problem is evident and you can easily find it.