$smary模板缓存
<?php
//引入配置文件
$fillname="../cache/testhuancun.html";
//设置一个缓存时间
$time=; //判断如果缓存文件不存在的话
if(!file_exists($fillname) || filemtime($fillname)+$time<time())
{
//开启缓存
ob_start(); include("../init.inc.php");
include("../DBDA.class.php");
$db=new DBDA();
$sql="select * from nation";
$attr=$db->Query($sql);
$smarty->assign("nation",$attr);
$smarty->display("test.html");
//把内存里面的内容读出来
$nr=ob_get_contents();
//将读到的内容存放到缓存文件
file_put_contents($fillname,$nr); //清除缓存
ob_flush();
echo "##########################"; }
//如果缓存文件存在的话
else
{
include($fillname); }
随机推荐
- PullToRefreshScrollView的上拉加载、下拉刷新
eclipse中的项目: //注意:此刷新功能是使用的第三方的PullToRefreshScrollView,因此需要导入第三方library作为依赖 步骤:导入第三方library,依赖:点击你的应 ...
- CodeForces 687C The Values You Can Make(动态规划)
这个也可以说是一个01背包了,里面也有一些集合的思想在里面,首先dp方程,dp[i][j]代表着当前数值为i,j能否被构成,如果dp[i][j] = 1,那么dp[i+m][j] 和 dp[i+m][ ...
- POJ 1523 SPF (去掉割点能形成联通块的个数)
思路:使用tarjan算法求出割点,在枚举去掉每一个割点所能形成的联通块的个数. 注意:后来我看了下别的代码,发现我的枚举割点的方式是比较蠢的方式,我们完全可以在tarjan过程中把答案求出来,引入一 ...
- HDU - 1083 Courses /POJ - 1469
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1083 http://poj.org/problem?id=1469 题意:给你P个课程,并且给出每个课 ...
- linux常用命令 、查看日志、web排查
linux常用命令 ps aux|grep xxx (比如 ps aux|grep tomcat ps aux|grep tomcat-portalvip ps aux|grep nginx 等) r ...
- 判断浏览器增加标签 encodeURIComponent
var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; var lx; (s = ua.match(/msie ([\d.]+ ...
- typedef void far *LPVOID 的具体定义
首先这里的far,在32位系统已经废除不用了.它是C/C++语言在16位系统中用以标明指针是个远指针的修饰符. 远指针是说指针所指向的地址已经超出了64K(2的十六次方),所以需要使用DS加偏移量的方 ...
- jquery 事件注册 与重复事件处理
<!doctype html><html lang="us"><head><meta charset="utf-8"& ...
- 不停止MySQL服务增加从库的两种方式【转载】
现在生产环境MySQL数据库是一主一从,由于业务量访问不断增大,故再增加一台从库.前提是不能影响线上业务使用,也就是说不能重启MySQL服务,为了避免出现其他情况,选择在网站访问量低峰期时间段操作. ...
- s-palindrome
s-palindrome Let's call a string "s-palindrome" if it is symmetric about the middle of the ...