手机
当前位置:查字典教程网 >编程开发 >php教程 >php 缓存函数代码
php 缓存函数代码
摘要:复制代码代码如下:***@说明:文件缓存输出*@参数:$cachefile=>cache文件(绝对路径)*@参数:$pertime=>缓存输...

复制代码 代码如下:

**

* @说明: 文件缓存输出

* @参数: $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 缓存函数代码】相关文章:

php eval函数一句话木马代码

php实现的简单日志写入函数

php分页函数

模拟xcopy的函数

php操作redis缓存方法分享

php curl 上传文件代码实例

php实现简单的语法高亮函数实例分析

php中file_exists函数使用详解

php页面缓存ob系列函数介绍

PHP中把对象转换为关联数组代码分享

精品推荐
分类导航