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!
You can check any INI parameter in PHP using the ini_get method. http://php.net/ini_get
ini_get
ini_get('output_buffering');
Similarly, you can change most of the INI settings with ini_set :
ini_set
ini_set('output_buffering', 'on');
You can access the output_buffering value in the php.ini file by doing:
output_buffering
var_dump(ini_get('output_buffering'));
But I think you are looking for ob_get_level() (or ob_get_status() ):
ob_get_level()
ob_get_status()
var_dump(ob_get_level());
Returns the level of nested output buffering handlers, or zero if output buffering is not active .
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.
phpinfo();
I think you can go
if(!ob_start()) { }