fsync

Synchronizes changes to the file (including meta-data)

&reftitle.description; `bool` `fsync` `resource` `stream`

This function synchronizes changes to the file, including its meta-data. This is similar to `fflush`, but it also instructs the operating system to write to the storage media.

&reftitle.parameters;

`stream`

- &fs.validfp.all;
&reftitle.returnvalues;

&return.success;

&reftitle.examples;

### `fsync` example

    <?php

    $file = 'test.txt';

    $stream = fopen($file, 'w');
    fwrite($stream, 'test data');
    fwrite($stream, "\r\n");
    fwrite($stream, 'additional data');

    fsync($stream);
    fclose($stream);
    ?>

&reftitle.seealso;

- `fdatasync`
- `fflush`