Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# PHP Function fflush()

## 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

Parameter | Description
--- | ---
handle | The 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:

Advertisement

Online Image Processing

Indian Baby Names