Is it OK to have ob_start()
in the beginning of all PHP pages?
If I don't do this, I get the "headers already sent" error.
Is it OK to have ob_start()
in the beginning of all PHP pages?
If I don't do this, I get the "headers already sent" error.
It is "ok" but you should really fix your script to not output stuff prematurely and save the output for the end. But you can just change a setting in .htaccess
or the php.ini
the below is the for .htaccess:
php_value output_buffering On
php_value output_handler mb_output_handler
This would be preferred, in my opinion, instead of adding ob_start
to the top of all your scripts.
However, you really should fix the problem at its core. IE: Save output for the end of the script.