php smarty安装,php smarty 安装 、配置、使用 及缓存cache的配置使用
cache 使用:
cache配置:
$smarty->cache_dir?=?"/caches/";??//緩存目錄
$smarty->caching?=?true;??//開啟緩存,為flase的時侯緩存無效
$smarty->cache_lifetime?=?60;??//緩存時間
cache清除和使用:
$smarty->display('cache.tpl', cache_id); //創建帶ID的緩存
cache.tpl //模板文件
$smarty->clear_all_cache(); //清除所有緩存
$smarty->clear_cache('index.htm'); //清除index.tpl的緩存
$smarty->clear_cache('index.htm',cache_id); //清除指定id的緩存
smarty 安裝配置 說明:
下載smarty解壓 將libs目錄?? copy到項目主目錄下,至少建立如下如下文件夾:templates? templates_c? configs? cache
index.php
include("libs/Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = './templates/';
$smarty->compile_dir? = './templates_c/';
$smarty->config_dir?? = './configs/';
$smarty->cache_dir??? = './cache/';
$smarty->caching????? = true;
$smarty->cache_lifetime = 60;
$smarty->left_delimiter = "
$smarty->right_delimiter = "}>";
$smarty->assign("title", "垃圾");
$smarty->assign("content","測試用的網頁內容00");
$smarty->display("index.tpl",cache_id);
?>
index.tpl模板文件
總結
以上是生活随笔為你收集整理的php smarty安装,php smarty 安装 、配置、使用 及缓存cache的配置使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php curl for win7_解决
- 下一篇: php-fpm 没有启动脚本,php-f