PHP - How Detect if Output Buffering is Enabled
10,289
Solution 1
You can check any INI setting in PHP with the ini_get
method. http://php.net/ini_get
ini_get('output_buffering');
Likewise, you can change most INI settings with ini_set
:
ini_set('output_buffering', 'on');
Solution 2
You can access the output_buffering
value in the php.ini file by doing:
var_dump(ini_get('output_buffering'));
But I think what you are looking for is ob_get_level()
(or ob_get_status()
):
var_dump(ob_get_level());
Returns the level of nested output buffering handlers or zero if output buffering is not active.
Related videos on Youtube
Author by
usnidorg
Updated on June 04, 2022Comments
-
usnidorg almost 2 years
Is there a simple way to detect in PHP if output_buffering is enabled in php.ini? I'd like to be able to display a message if it is not enabled.
Within my application I tried using an htaccess file to automatically enable it but it seems it does not work in all server environments and in some cases it gives a nasty error.
Thank you very much!
-
Admin about 13 years
-
-
usnidorg about 13 yearsFantastic. Thank you very much!