我重新安装了 Apache,并从 PHP 5.3 切换到 5.6。一切正常,除了我在调用 ob_start()
时遇到此错误:
Cannot use output buffering in output buffering display handlers
我尝试在 PHP 中启用输出缓冲,但仍然出现此错误:
output_buffering = 4096
最佳答案
您正在尝试在缓冲区回调中启动输出缓冲区。如果您使用此代码,它将生成该错误。但是,如果您从回调函数中删除 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();
关于php - 不能在输出缓冲显示处理程序中使用输出缓冲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33936067/