Php/ref output flush

来自菜鸟教程
跳转至:导航、​搜索

PHP flush()函数

Output PHP输出控制功能

在脚本运行完成之前,将字符串输出到浏览器:

<?php
// 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);

// Use flush() to send the string to the browser

  flush();

// Display the rest of the content three seconds later

  sleep(3);
echo "<br>";
echo "Hello World!";
?>

定义和用法

The flush() 函数请求服务器将其当前缓冲的输出发送到浏览器。服务器配置可能并不总是允许这种情况发生。

句法

flush();

技术细节

PHP版本: 4+

Output PHP输出控制功能