php 缓存函数代码
2008-08-27 00:00
549 查看
** * @说明: 文件缓存输出 * @参数: $cachefile => cache文件(绝对路径) * @参数: $pertime => 缓存输出的间隔时间 * @参数: $sql => sql语句 * @参数: $templatefile => 模板文件名称(绝对路径) * www.php100.com 来自 **/ function __cache($cachefile,$pertime,$sql,$templatefile) { global $db; if(time() - @filemtime($cachefile) >= $pertime) { $query = $db->query($sql); while($r=$db->fetch($query)) { $cachelist[] = $r; } include $templatefile.'.php'; $cacheserialize = serialize($cachelist); file_put_contents($cachefile,$cacheserialize); }else{ $cachelist = unserialize(file_get_contents($cachefile)); include $templatefile.'.php'; } }
相关文章推荐
- PHP下利用header()函数设置浏览器缓存的代码
- PHP下利用header()函数设置浏览器缓存的代码
- php 写入缓存文件、读取缓存文件的函数代码
- PHP下利用header()函数设置浏览器缓存的代码
- php 禁止页面缓存代码
- 使用php代码加亮函数构造php小后门
- PHP汉字转换拼音的函数代码
- php的opcache缓存扩展(php页面代码刷新速度)
- PHP htmlspecialchars() 函数实例代码及用法大全
- php xml分析函数代码第1/2页
- PHP格式化显示时间date()函数代码
- PHP的php_strip_whitespace函数描述,以及手册中写的代码压缩函数-可看看函数是怎么实现的
- php调用C代码的方法详解和zend_parse_parameters函数详解
- PHP常用函数、代码整理
- PHP自定义函数收代码
- php分页函数示例代码(转)