当前位置:Gxlcms > PHP教程 > php缓存设计_PHP教程

php缓存设计_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

//本功能主要是利用文件修改时间函数filemtime与现在时间作减法判断是否更新内容。

$cahetime=2;//设置过期时间
$cahefile="cahe.txt";//读写文本

if(file_exists($cahefile) && time()-$cahetime< filemtime($cahefile)){

echo file_get_contents($cahefile);
}
else {
file_put_contents($cahefile,date("y-m-d H:i:s",time()));
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632268.htmlTechArticle//本功能主要是利用文件修改时间函数filemtime与现在时间作减法判断是否更新内容。 ?php $cahetime=2;//设置过期时间 $cahefile=cahe.txt;//读写文本...

人气教程排行