Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遇到了 ob_start 的问题。不知道这笔交易是什么,但我已经将其归结为最简单的测试用例......仍然无济于事。我希望这段代码将“bar”输出到标准输出,但我什么也没得到,我的错误日志中也没有错误。
<?php function gzhandler_ex($buffer, $mode) { echo 'bar'; } ob_start('gzhandler_ex'); echo 'foo'; ob_flush();
我以前从未见过这种情况,但我通常不使用这样的回调。
您的处理函数应该return是您想要输出的内容,而不是回显它。
return
function gzhandler_ex($buffer, $mode) { return 'bar'; }
此外,ob_flush()在脚本末尾调用时是不必要的;它是隐含的。
ob_flush()