【问题标题】:PHP: What happens after ending output bufferingPHP:结束输出缓冲后会发生什么
【发布时间】:2013-08-05 13:04:04
【问题描述】:

我有一些执行以下操作的代码:

<?php
ob_flush();
ob_start();
echo $something;
ob_end_flush();

echo $another_thing;
?>

我可以看到$something,但看不到$another_thing;

根据手册 ob_end_flush() 只是关闭输出缓冲,所以如果是这样的话,为什么我看不到 $another_thing; 就像我在没有任何输出缓冲的情况下编写的一样:

<?php
echo $something;
echo $another_thing;
?>

虽然我看不出这应该起作用的原因,但我决定尝试在echo $another_thing; 之后调用flush()ob_flush(),但这也无济于事。

执行此操作的正确方法是什么,为什么上述方法不起作用?

谢谢

【问题讨论】:

  • 为我工作 phpfiddle.org/main/code/06s-kmj ,也许 $another_thing 是空的或无法打印?
  • 谢谢 - 请看我下面的回答,结果证明输出缓冲与它无关。

标签: php buffer output flush output-buffering


【解决方案1】:

原来问题出在其他地方!

在上面设置$something;的过程中,我在一个大模板中调用了一系列函数,并且埋在其中的某个地方有一个exit语句,所以问题与输出缓冲无关!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-08
    相关资源
    最近更新 更多