Ite*_*tor 9 php apache output-buffering ob-start
我重新安装了Apache,并从PHP 5.3切换到5.6.一切正常,但我得到这个错误,当调用ob_start():
Cannot use output buffering in output buffering display handlers
Run Code Online (Sandbox Code Playgroud)
我试图在PHP中启用输出缓冲,但我仍然收到此错误:
output_buffering = 4096
Run Code Online (Sandbox Code Playgroud)
您正在尝试在缓冲区回调中启动输出缓冲区.如果您使用此代码,则会生成该错误.但是如果你ob_start()从回调函数中删除它就可以了.
<?php
error_reporting(-1);
function callback($buffer){
//you can't call ob_start here
ob_start();
return (str_replace("apples", "oranges", $buffer));
}
ob_start("callback");
?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php
ob_end_flush();
Run Code Online (Sandbox Code Playgroud)
尽管这是一个老问题,但我只是想补充一点,当系统在缓冲时内存不足时,也会发生相同的错误。
如果是这种情况,本主题中提到的错误后面将始终出现错误Allowed memory size of xxx bytes exhausted。
可能您在输出缓冲回调中使用缓冲函数,如 php ob_start output_callback文档中所述,这是不可能的。如果不是,它应该是您使用的输出处理程序,请检查您的 php.ini 并尝试将其值设置为“none”(如果可能)。