Filemtime/cachetime我哪里错了?

Gar*_*ary 2 php scripting image filemtime

我想要做的是检查一个图像的年龄,如果它超过60分钟,然后运行另一个PHP页面来获取图像,否则如果不到60分钟的时间什么都不做....

该脚本没有打开第二页(radartest.php)并运行它来更新图像,所以需要一个命令告诉它作为脚本运行.

<?php
$imagename='./radar/auck0.png';
$cachetime = 3600;
    //Start the caching of the images........
    if (file_exists($imagename) and filemtime($imagename) + $cachetime > time()) {
          echo("radartest.php");
        } else {
  null; //do nothing
}
?>
Run Code Online (Sandbox Code Playgroud)

syl*_*bre 5

filemtime返回的结果被缓存.

这只是猜测,但是如果你经常使用这段代码,你可能不得不使用clearstatcache函数:http://php.net/manual/en/function.clearstatcache.php