Does not flush st_atime, st_mtime or st_size.
If you need to use filesize after a write you will need need fsync() or fflush() instead.
(PHP 8 >= 8.1.0)
fdatasync — Sincroniza los datos (pero no los metadatos) con el fichero
Esta función sincroniza el contenido del stream
en el soporte de almacenamiento, al igual que fsync(),
pero no sincroniza los metadatos de los ficheros.
Cabe señalar que esta función es diferente solo en sistemas POSIX.
En Windows, esta función es un alias de fsync().
stream
El fichero al que se apunta debe ser válido, y debe apuntar a un fichero abierto por fopen() o fsockopen() (y que todavía no esté cerrado por fclose()).
Ejemplo #1 Ejemplo de fdatasync()
<?php
$file = 'test.txt';
$stream = fopen($file, 'w');
fwrite($stream, 'test data');
fwrite($stream, "\r\n");
fwrite($stream, 'additional data');
fdatasync($stream);
fclose($stream);
?>
Does not flush st_atime, st_mtime or st_size.
If you need to use filesize after a write you will need need fsync() or fflush() instead.