Archive

Archive for September, 2011

Why you should Turn off Output buffering in php when developing code for others…

September 29th, 2011 2 comments

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

Categories: php Tags: