PHP fflush() Function

Definition and Usage

The fflush() function outputs buffered content to the file.

Syntax

fflush(file)
Parameter Description
file Required. Specifies the file stream to be checked.

Description

This function forces all buffered output to be written file pointed to by the file handle. If successful, it returns true, otherwise it returns false.

The file pointer must be valid and must point to a resource fopen() or fsockopen() successfully opened (but not yet fclose() close) file.

Example

<?php
file = fopen("test.txt","r+");
// Some code
fflush($file);
?>