[英]changing the file's last modified time through touch() and getting the result with filemtime()
所以我試圖獲取文件的最后修改日期,然后將其更新到當前時間,但是當我查看結果時,我在$ oldtime和$ newtime中獲得了SAME時間戳
$file = 'test.txt';
$oldtime = filemtime($file);
touch($file, time());
$newtime = filemtime($file);
echo '<h1>old</h1>';
print_r(getdate($oldtime));
echo '<h1>new</h1>';
print_r(getdate($newtime));
touch
文件后使用clearstatcache
獲取正確的修改時間值。
因為您之前使用過filemtime
,所以緩存了結果,而在第二次調用時,結果從該緩存中提取而不是直接檢查文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.