是否可以在php脚本结束之前发送输出


Is it possible to send the output before end of the php script?

是否可以在脚本结束前发送php脚本的输出,以便我们可以对输出进行任何不相关的操作?

是的,您可以:

在脚本顶部定义以下内容:

ini_set("implicit_flush", 1);
while (@ob_end_flush());
ob_implicit_flush(true);

在任何输出(echo-print或print_r)之后,调用这两个函数来刷新它:

flush();
ob_flush();