Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function fflush()


previous

Advertisements

Syntax

bool fflush ( resource $handle );

Definition and Usage

This function forces a write of all buffered output to the resource pointed to by the file handle.

Paramters

ParameterDescription
handleThe file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).

Return Value

Returns TRUE on success or FALSE on failure.

Example

Following is the usage of this function:

<?php
if ($f = fopen('myfile.txt', 'r')) do {
    $line = fgets($f);
    echo "$line";
    // do any stuff here...
} while (!feof($f));
fflush($f);
// do any stuff here...
fclose($f);
?>

This will produce following result:


previous Printer Friendly

Advertisements


  

Advertisements