PHP Output Buffering Check? [duplicate]

心不动则不痛 提交于 2019-12-10 10:34:57

问题


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!


回答1:


You should be able to do this with ini_get(). I didn't test it, but I am pretty sure it will suit your needs since ini_get() is used for that purpose: checking php.ini options.




回答2:


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.



来源:https://stackoverflow.com/questions/5506411/php-output-buffering-check

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!