Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Output Buffering Check? [duplicate]

Possible Duplicate:
PHP - How Detect if Output Buffering is Turned On

How can I check in PHP if output_buffering is set to On? I have to troubleshoot a site and I have no access to the hosting panel.

Something like:

if(output_buffering == 'On')
{
    echo 'It is On';
}
else
{
    echo 'It is NOT On';
}

Thank you!

like image 310
usnidorg Avatar asked Dec 05 '25 16:12

usnidorg


1 Answers

if(ob_get_level() > 0){
   //there are some buffers active.
}


$ php -d output_buffering=1 -r'var_dump(ob_get_level());'
int(1)
$ php -d output_buffering=0 -r'var_dump(ob_get_level());'
int(0)

It does however check whether there is an output buffer active, not what the actual setting of PHP itself is. A manual ob_start() (or more then one) will also increase the level. Usually this is more interesting then the actual output_buffering setting. If you actually need that, fo with the ini_get answer.

like image 200
Wrikken Avatar answered Dec 08 '25 05:12

Wrikken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!