PDA

View Full Version : PHP output buffering


Gerrit
January 13th, 2008, 17:20
Do I need to end output buffering when I started it with ob_start(); ?

Or better, what are the possible problems/unwanted effects if I don't end it?

The reason for asking is I found out that starting output buffering fixes a 'cannot add header information' warning.
Ending the buffering gets complicated because the script is used by several pages. If there's no need to end/close/stop the buffering I happily leave it on and move on with my work. ;)

Dan
January 13th, 2008, 20:38
From http://us3.php.net/manual/en/function.ob-end-flush.php

ob_end_flush() isn't needed in MOST cases because it is called automatically at the end of script execution by PHP itself when output buffering is turned on either in the php.ini or by calling ob_start().

Now, if ob_end_flush() was required, you could use auto_append_file to automatically append a file to the end of every script you run. It's listed here: http://php.net/manual/en/ini.core.php

Gerrit
January 13th, 2008, 22:08
Thanks Dan!