文章来源:
100素材网
更新时间:
2014-08-03 20:07:11
php缓存设置 php缓存类 php缓存输出 php缓存文件
以下代码实现php缓存功能主要是利用文件修改时间函数filemtime与现在时间进行减法判断是否更新内容
<?php
//本php缓存功能主要是利用文件修改时间函数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()));
}
?>
浏览次数次
下一篇文章: 解析php安全性问题中的:Null 字符问题


推荐阅读:
