array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.fdatasync.php', 1 => 'fdatasync', ), 'up' => array ( 0 => 'ref.filesystem.php', 1 => '文件系统函数', ), 'prev' => array ( 0 => 'function.fclose.php', 1 => 'fclose', ), 'next' => array ( 0 => 'function.feof.php', 1 => 'feof', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/filesystem/functions/fdatasync.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 8 >= 8.1.0)
fdatasync — 同步文件数据(不包含元数据)
此函数同步 stream
的内容到存储介质,就像是 fsync()
所做的那样,但不会同步文件元数据。注意,此函数仅在 POSIX 系统中有实际区别。在 Windows 中,是 fsync()
的别名。
示例 #1 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);
?>