PHP 中的 fflush() 函数

phpprogrammingserver side programming

fflush() 函数将输出刷新到打开的文件。此函数强制将所有缓冲输出写入文件句柄指向的资源。

语法

fflush(file_pointer)

参数

  • file_pointer − 指定打开的文件流。

返回

fflush() 函数返回。

  • 成功时为 TRUE
  • 失败时为 FALSE

示例

<?php
   $file_pointer = fopen("one.txt","r+");
   fflush($file_pointer);
?>

输出

test line

让我们看另一个例子。

示例

<?php
   $file_pointer = fopen("two.txt", "r");
   $res = fgets($file_pointer);
   while(! feof($file_pointer))
   fflush($check);
   fclose($file_pointer);
?>

输出

Java is a programming language.
JavaScript is a scripting language.

相关文章