PHP Output Buffering Check? [duplicate]

一个人想着一个人 提交于 2019-12-06 05:04:29

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.

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.

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