我正在尝试做的是检查一个图像的年龄,如果它超过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
}
?>发布于 2012-09-06 15:45:41
对filemtime返回的结果进行缓存。
这只是一种猜测,但是如果您过于频繁地使用这段代码,则可能必须使用clearstatcache函数:http://php.net/manual/en/function.clearstatcache.php
发布于 2010-07-10 20:03:14
另外,你使用的是不是应该是include('radartest.php');的echo('radartest.php');?
即。
<?php
$imagename='./radar/auck0.png';
$cachetime = 3600;
//Start the caching of the images........
if (file_exists($imagename) && (filemtime($imagename) + $cachetime) > time()) {
include ("radartest.php");
} else {
null; //do nothing
}?>
发布于 2010-07-10 19:40:40
不确定是否可能是运算符优先级。您使用的是"and“,它的优先级低于&&请尝试将表达式括起来以强制优先级:
if ((file_exists($imagename)) && ((filemtime($imagename) + $cachetime) > time())) {https://stackoverflow.com/questions/3218956
复制相似问题