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);
}
160726 smarty 笔记(2)的更多相关文章
- 160726 smarty 笔记(1)
模板里面显示变量:1.变量要写在Smarty标记之间,变量名以$开头<{$test}>2.支持所有类的数据,包括数组(关联数组),对象关联数组在模板显示的时候,除了可以使用php语法之外, ...
- smarty笔记
smarty 笔记display():把html包含进来然后用正则匹配php变量把匹配好的页面重新保存inclue载入刚才的保存的页面 1.smarty原理2.smarty安装3.smarty模板设计 ...
- Smarty笔记 和20个常用的变量操作符
什么是Smarty变量操作符php模板引擎smarty内置的一些操作函数,我们称之为变量操作符,变量操作符可用于操作变量,自定义函数和字符.(跟我PHP中常用的PHP内部函数类似)他可以帮助我们完成很 ...
- smarty之缓存笔记
smarty缓存技术 在smarty中,缓存分为:普通缓存,单模版都缓存,局部缓存. 缓存:1:首选打开缓存配置项:$smarty->caching=true; 2:缓存生命周期的配置选项:$s ...
- Smarty学习笔记(二)
1.引用 {include file="xxx.xxx" sitename="xxx"} 向引入的文件传入变量: {include file="xxx ...
- Smarty学习笔记(一)
1.Smarty的配置: 将lib的内容复制到自己的工程,然后引入 实例化和配置Smarty基本属性: $smarty = new Smarty(); $smarty->left_delimit ...
- PHP-MVC和Smarty初探笔记
在慕课网上学习了PHP的MVC的基础知识,记录一下笔记: 等待更新~
- smarty详细使用教程(韩顺平smarty模板技术笔记)
MVC是一种开发模式,强调数据的输入.处理.显示是强制分离的 Smarty使用教程1.如何配置我们的smarty解压后把libs文件夹放在网站第一级目录下,然后创建两个文件夹templates 存放模 ...
- Yaf + Smarty 整合笔记
Yaf真的是太简单了,简单到使用mvc的时候在view里面需要手写php脚本.因此考虑整合一下smarty模板引擎.随心所欲也正是yaf的魅力 Yaf 安装 这里简单说一下yaf的安装,已经是非常无脑 ...
随机推荐
- CefGlue 学习杂记
1. hg clone代码回来后,还要下载对应的cef dll . 从http://xilium.bitbucket.org/cefglue/ 选择对应的. 然后把dll和resource目录里的内 ...
- js后台常用树形菜单
来源:http://www.sucaihuo.com/js/1093.html demo: http://www.sucaihuo.com/jquery/10/1093/demo/
- Socket的三个关联函数
/*lrs_save_param将静态或接收到的缓冲区保存到参数中*/lrs_save_param (char *s_desc, char *buf_desc, char *param_name, i ...
- 【Python】python-memory-management
http://deeplearning.net/software/theano/tutorial/python-memory-management.html#python-memory-managem ...
- C++之运算符重载
C++ Code 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...
- sizeof 数组与指针
在学习指针的时候,得到指针的定义和数组的定义一样,但是这时候就很好奇,指针只是一个地址,那数组和指针一样的话,sizeof时怎么得知其长度呢. 于是百度了下面的回复: 千万不要把数组名看成指针,尽管有 ...
- 苹果发布【新开发语言】Swift
Swift is a multi-tenant, highly scalable and durable object storage system that was designed to stor ...
- jquery 判断ul下是否存在li
$("ul").has("li").length > 0;$("ul > li").length > 0;$(" ...
- Excel 信息对比_数组版
Sub LOOKUP_UChur() Dim i As Long '=== sourceWorksheet = 数据源表名称 Dim sourceWorksheet As Worksheet Dim ...
- HYSBZ 1036(树的统计Count)
题目链接:传送门 题目大意:中文题,略 题目思路:树链剖分裸题. 闲谈:树链越练越熟练了 #include <iostream> #include <cstdio> #incl ...