使用smarty生成页面缓存

来源:互联网 发布:ps4游戏卖给淘宝店家 编辑:程序博客网 时间:2024/06/11 01:50

01.php

 //引入smarty include "libs/Smarty.class.php"; $smarty = new Smarty;//定义输出页面目录 $smarty -> setTemplateDir("./view/"); $smarty -> setCompileDir("./view_c/"); //开启缓存 $smarty -> caching = 1; $brand = $_GET['brand']; $price = $_GET['price']; $network = $_GET['network']; $big = $_GET['big'];// display(模板,mark1|mark2|mark3|mark4) $smarty ->display('01.html',$brand."|".$price."|".$network."|".$big); /* clearCache(模板名称); //删除该模板对应的全部缓存文件 clearCache(模板,标志); // 删除指定模板,指定标志开始的全部缓存文件 clearCache(); //删除全部缓存文件 clearCache(null,标志) //删除指定标志开始的全部缓存文件,不考虑是哪个模板的  */

01.html

<!doctype html><html lang="en"> <head>  <meta charset="UTF-8">  <meta name="Generator" content="EditPlus®">  <meta name="Author" content="">  <meta name="Keywords" content="">  <meta name="Description" content="">  <title>smarty缓存集合</title> </head> <body>    <h2>smarty缓存集合</h2>    <ul>    商品展示:<br/>    <h1>条件</h1>   品牌:{$smarty.get.brand}<br/>  价格:{$smarty.get.price}<br/>  网络:{$smarty.get.network}<br/>  屏幕:{$smarty.get.big}<br/>    </ul> </body></html>

02.php 清楚缓存

 //引入smarty include "libs/Smarty.class.php"; $smarty = new Smarty; $smarty -> setTemplateDir("./view/"); $smarty -> setCompileDir("./view_c/"); /* clearCache(模板名称); //删除该模板对应的全部缓存文件 clearCache(模板,标志); // 删除指定模板,指定标志开始的全部缓存文件 clearCache(); //删除全部缓存文件 clearCache(null,标志) //删除指定标志开始的全部缓存文件,不考虑是哪个模板的  */ echo $smarty -> clearCache('07.html','htc|1|cmcc|4');
0 0
原创粉丝点击