PHP-如何检测是否打开了输出缓冲 [英] PHP - How Detect if Output Buffering is Turned On
本文介绍了PHP-如何检测是否打开了输出缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果php.ini中的output_buffering为ON,是否有一种简单的方法可以在PHP中进行检测?我希望能够显示一条未打开的消息.
Is there a simple way to detect in PHP if output_buffering is ON in php.ini? I'd like to be able to display a message if it is not turned on.
在我的应用程序中,我尝试使用htaccess文件自动将其打开,但是它似乎无法在所有服务器环境中正常工作,并且在某些情况下会产生令人讨厌的错误.
Within my application I tried using an htaccess file to automatically turn it on but it seems it does not work in all server environments and in some cases it gives a nasty error.
非常感谢您!
推荐答案
您可以使用ini_get
方法检查PHP中的任何INI设置. http://php.net/ini_get
You can check any INI setting in PHP with the ini_get
method. http://php.net/ini_get
ini_get('output_buffering');
同样,您可以使用ini_set
更改大多数INI设置:
Likewise, you can change most INI settings with ini_set
:
ini_set('output_buffering', 'on');
这篇关于PHP-如何检测是否打开了输出缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文