<?php header("content-type:text/html;charset=utf-8"); $pdo=new PDO("mysql:host=localhost;dbname=practise","root","root"); $pdo->exec("set names utf8"); $id=$_GET['id']; $file=$id.".html"; if(file_exists($file)){ $time=filemtime($file); if((time()-$time)<30){ header("Location:$file"); }else{ unlink($file); ob_start(); $list=$pdo->query("select * from shot where id=$id")->fetch(PDO::FETCH_ASSOC); include "b.html"; $content=ob_get_contents(); ob_end_clean(); file_put_contents($file,$content); } }else{ ob_start(); $list=$pdo->query("select * from shot where id=$id")->fetch(PDO::FETCH_ASSOC); include "a.html"; $content=ob_get_contents(); ob_end_clean(); file_put_contents($file,$content); }
PHP生成静态详情页面核心代码(30秒重新生成)
最新推荐文章于 2021-03-31 20:29:18 发布