配置文件:
1、配置文件定义一些常量或变量,其中以#开始的是注释,结束时不用分号
2、变量当中有空格是用双引号
pagetitle="main menu"
3、[]下的变量时局部变量 []中是作用于的声明
当全局变量和局部变量重名时执行局部变量 局部变量的优先级>全局变量
隐藏域前加. [.database]
4、引用配置文件
<{config_load file="配置文件"}>
5、Smarty保留变量的返回值可直接调用
$smarty.get.a
$smarty.post.name
$smarty.foreach.name.total
index.php
include("libs/Smarty.class.php");
$smarty=new Smarty();
$arr=array(1,2,3,4,5,6,7,8,9);
$smarty->reInitSmarty("demo/templates","demo/templates_c","demo/configs");
$smarty->assign("array",$arr);
$smarty->display("index.tpl");
index.tpl
foreach保留变量
<{foreach from=$array item=value name=a}>
<{$value}>
<{/foreach}>
总共<{$smarty.foreach.a.total}>条记录
$smarty.section.name.
index.tpl
<{section name=a loop=$array}>
第<{$smarty.section.a.index}>条记录是<{$array[a]}><br />
<{/section}>