PHP生成静态详情页面核心代码(30秒重新生成)

来源:互联网 发布:淘宝联盟找优惠券 编辑:程序博客网 时间:2024/06/13 21:27
<?phpheader("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);}
1 0
原创粉丝点击