zoukankan      html  css  js  c++  java
  • 160726 smarty 笔记(2)

    <?php
    //取当前页
    $p=1;
    if(!empty($_GET["page"]))
    {
    $p=$_GET["page"];
    }
    //定义页面缓存文件的路径
    $filename="../cache/0726huancun{$p}.html";
    //定义缓存有效期
    $cachetime=25;
    //判断文件是否存在
    if(!file_exists($filename) || filemtime($filename)+$cachetime<time())
    {
    //开启内存缓存
    ob_start();
    include ("../DBDA.php");
    include ("../init.inc.php");
    include ("page.class.php");
    $db=new DBDA();
    //取总条数
    $szs = "select count(*) from car";
    $zs = $db->StrQuery($szs);
    //造分页对象
    $page = new Page($zs,5);
    $xinxi = $page->fpage();
    //查询汽车表信息
    $sql="select * from car ".$page->limit;
    $attr=$db->Query($sql);
    $smarty->assign("car",$attr);
    $smarty->assign("xinxi",$xinxi);
    $smarty->display("0726hcfy.html");
    //从内存缓存中获取页面代码
    $content=ob_get_contents();
    //将获取到的内容放到缓存文件
    file_put_contents($filename,$content);
    //清理缓存
    ob_flush();
    echo "######################################";
    }
    else{
    include($filename);
    }
    

      

  • 相关阅读:
    CSUFT 1002 Robot Navigation
    CSUFT 1003 All Your Base
    Uva 1599 最佳路径
    Uva 10129 单词
    欧拉回路
    Uva 10305 给任务排序
    uva 816 Abbott的复仇
    Uva 1103 古代象形文字
    Uva 10118 免费糖果
    Uva 725 除法
  • 原文地址:https://www.cnblogs.com/pangchunlei/p/5717956.html
Copyright © 2011-2022 走看看