尝试运行
<?php
echo filemtime("test.txt")."\n";
sleep(4);
file_put_contents("test.txt", "test");
echo filemtime("test.txt")."\n";
?>
对我来说命令行打印:
1343490984
1343490984
这不可能吧?
最佳答案
Note: The results of this function are cached. See
clearstatcache()
for more details.
在再次调用 filemtime()
之前,您需要先调用 clearstatcache()
:
echo filemtime("test.txt")."\n";
sleep(4);
file_put_contents("test.txt", "test");
clearstatcache();
echo filemtime("test.txt")."\n";
关于php - 尽管对文件进行了更改,但 filemtime() 在执行期间保持不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11702553/