PHP - how to determine if output buffering is enabled

Is there an easy way to detect in PHP if output_buffering is included in php.ini? I would like to be able to display a message if it is not included.

In my application, I tried to use the htaccess file to automatically include it, but it does not seem to work in all server environments, and in some cases it gives an unpleasant error.

Many thanks!

+7
source share
4 answers

You can check any INI parameter in PHP using the ini_get method. http://php.net/ini_get

 ini_get('output_buffering'); 

Similarly, you can change most of the INI settings with ini_set :

 ini_set('output_buffering', 'on'); 
+6
source

You can access the output_buffering value in the php.ini file by doing:

 var_dump(ini_get('output_buffering')); 

But I think you are looking for 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 .

+18
source

plain

check

 echo ini_get('output_buffering'); 

or run the file calling the phpinfo(); function phpinfo(); , it will list all verifications containing values, check the value for 'output_buffering' in the list.

+1
source

I think you can go

 if(!ob_start()) { } 
-2
source

All Articles