Smarty模板简单配置与使用方法示例
发布时间:2020-12-12 21:32:30 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解Smarty模板简单配置与使用方法。供大家参考研究具体如下: 在Smarty目录中建立templates,templates_c,configs,cache目录。以便Smarty进行编译和缓存。 建立smarty_inc.php文件对smarty进行配置如下: caching=false; //开发是不建议开
本篇章节讲解Smarty模板简单配置与使用方法。分享给大家供大家参考,具体如下: 在Smarty目录中建立templates,templates_c,configs,cache目录。以便Smarty进行编译和缓存。 建立smarty_inc.php文件对smarty进行配置如下: caching=false; //开发是不建议开启缓存
$smarty->template_dir="./templates"; //设置模板目录
$smarty->compile_dir="./templates_c"; //设置编译目录
$smarty->cache_dir="./cache"; //缓存文件夹
$smarty->cache_lifetime=60;
$smarty->left_delimiter = "<{"; //左定界符
$smarty->right_delimiter = "}>"; //右定界符
?>
行测试,在根目录下建立index.php文件: assign("name",$val);
$smarty->display("index.html");
?>
在templates下建立index.html模板:
测试页面
<{foreach from=$name item=x}>
数组内容:<{$x}> <{/foreach}> |