fflush
(PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8)
fflush — 將緩衝內容輸出到檔案
說明
fflush(resource
$handle
): bool
本函式強制將所有緩衝的輸出寫入
handle
檔案控制代碼所指向的資源。
成功時返回 true
, 或者在失敗時返回 false
。
檔案指針必須是有效的,必須指向由 fopen() 或 fsockopen() 成功打開的檔案(並還未由 fclose() 關閉)。
返回值
成功時返回 true
, 或者在失敗時返回 false
。
範例
示例 #1 File write example using fflush()
<?php
$filename = 'bar.txt';
$file = fopen($filename, 'r+');
rewind($file);
fwrite($file, 'Foo');
fflush($file);
ftruncate($file, ftell($file));
fclose($file);
?>