本文目錄一覽:
最基本的php的smarty的配置問題,快瘋了
這裡是
$smarty-left_delimiter =”{%”;
$smarty-right_delimiter =”%}”;
邊界符帶了個%,所以後面也必須帶%
html
body
b{%$title%}/b
/body
/html
不過smarty邊界符一般這樣設置:
$smarty-left_delimiter =”!–{“;
$smarty-right_delimiter =”}–“;
使用smarty需要修改php配置么
使用smarty不需要修改php配置,一般只需要將下載的源代碼文件放置於網站目錄下,然後再使用時,用require/include引入即可。
示例代碼:
require ‘smarty/libs/Smarty.class.php’;
php smarty前後台模板路徑的配置問題
$smarty=new
smarty;
$smarty-template_dir=base_path.smarty_path.”templates/”;
$smarty-compile_dir=base_path.smarty_path.”templates_c/”;
$smarty-config_dir=base_path.smarty_path.”configs/”;
$smarty-cache_dir=base_path.smarty_path.”cache/”;
//定義定界符
$smarty-left_delimiter='{‘;
$smarty-right_delimiter=”}”;
$smarty2
=
new
smarty;
$smarty-template_dir=front_path.smarty_path.”templates/”;
$smarty-compile_dir=front_path.smarty_path.”templates_c/”;
$smarty-config_dir=front_path.smarty_path.”configs/”;
$smarty-cache_dir=front_path.smarty_path.”cache/”;
//定義定界符
$smarty-left_delimiter='{‘;
$smarty-right_delimiter=”}”;
不一定幾套,
你想弄幾套都行,你只要為你實例化的smarty對象做相應的設置就行啦。
PHP 中 smarty 要怎麼 配置?
首先要載入smarty類:Smarty.class.php
然後實例化這類:如$smarty=new Smarty()
主要的幾個基本配置:
$smarty-template_dir //設置模板目錄
$smarty – compile_dir //設置編譯目錄
$smarty – config_dir //設置配置文件目錄
$smarty- caching //設置緩存狀態
$smarty- cache_dir //設置緩存的路徑
$smarty – debugging //是否允許調試
$smarty – left_delimiter //設置左定界符
$smarty- right_delimiter //設置右定界符
$smarty – cache_lifetime //設置緩存的時間
使用一般就assign(); display();
原創文章,作者:EPGE,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/144459.html