我想检查是否更新了文件。但是连续调用file_put_contents不会更改filemtime或filesize的输出。我的脚本出问题了吗?
$myFile = 'MyFile.txt';
$newContent = 'Test_6';
file_put_contents($myFile, $newContent);
$lastUpdate1 = filemtime($myFile);
$filesize1 = filesize($myFile);
sleep(3);
$newContent = 'Test_77';
file_put_contents($myFile, $newContent);
sleep(3);
$filesize2 = filesize($myFile);
$lastUpdate2 = filemtime($myFile);
echo('$lastUpdate1: ' . $lastUpdate1 . '; $filesize1: ' . $filesize1 . '');
echo('$lastUpdate2: ' . $lastUpdate2 . '; $filesize2: ' . $filesize2 . '');
$ lastUpdate1:1562977837; $ filesize1:6
$ lastUpdate2:1562977837; $ filesize2:6