在产生输出的每个语句上立即将内容发送到浏览器:
<?php
// Turn on implicit flushing
ob_implicit_flush(1);
// Some browsers will not display the content if it is too short
// We use str_pad() to make the output long enough
echo str_pad("Hello World!", 4096);
// Even though the script is still running, the browser already can see the content
sleep(3);
?>
这个ob_implicit_flush()
函数启用或禁用隐式刷新。启用后,隐式刷新会在生成输出后立即将其直接发送到浏览器,以便调用flush()
功能不需要。
ob_implicit_flush(flag);
Parameter | Description |
---|---|
flag | When set to 1, implicit flushing is turned on. When set to 0, implicit flushing is turned off. |
PHP 版本: | 4+ |
---|
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!