首页 > IT职业 > IT职场 > php页面缓存的使用方法
function cache_start($dir,$expiretime){
$filename = $dir.'\'.sha1($_SERVER['REQUEST_URI']).'.html';
ob_start();
if(file_exists($filename) && (time()- filemtime($filename)
include($filename);
ob_end_flush();
exit();
}
mkdir($dir);
}
function cache_end($dir){
$filename = $dir.'\'.sha1($_SERVER['REQUEST_URI']).'.html';
echo $filename;
$fp = fopen($filename,'w');
fwrite($fp,ob_get_contents());
fclose($fp);
ob_end_flush();
}
$dir = "D:\\php";
cache_start($dir, 10);
cache_end($dir);
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2873/viewspace-2809507/ ,如需转载,请注明出处,否则将追究法律责任。