time()){echo file_get_contents($file);}else{unlink($file);//删除过期..._静态html数据存储">
当前位置:   article > 正文

怎么保存 html静态页面,静态页面怎么实现,就是把数据写入到html页面在缓存起来?...

静态html数据存储

static.php 文件

$file = "static.html";

$ctime =filectime($file);

$expr = 3600*24*10;//静态文件有效期,十天

if(file_exists($file)) {

if($ctime+$expr> time()){

echo file_get_contents($file);

}else{

unlink($file);//删除过期的静态页文件

ob_start();

//从数据库取出数据写入 static.html

$content = ob_get_contents();

file_put_contents($file,$content);//写入内容到对应静态文件中

ob_end_flush();

}

}else{

ob_start();

//从数据库取出数据写入 static.html

$content = ob_get_contents();

file_put_contents($file,$content);//写入内容到对应静态文件中

ob_end_flush();

}

?>

static.html 页面

静态页面

数据库的数据1

数据库的数据2

数据库的数据3

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/462355
推荐阅读
相关标签
  

闽ICP备14008679号