PHP fflush() Function

PHP fflush Function


Definition :

The fflush() function in PHP is an inbuilt function which is used to write all the buffered output to an open file. The fflush() function forces a write of all buffered output to the resource pointed to by the file handle. 

Syntax

   fflush(file)

Parameter
Parameter Description
file Required. Specifies the open file to write the buffered output to

Errors And Exception:

  1. The fflush() function results in errors if the file pointer is not valid.
  2. The file pointed must be opened by fopen() or fsockopen() and closed by fclose().

Given below example Write all buffered output to the open file:

Output : Hello World write in the "demo.text" file