Smarty自定义函数
作用:用于在模板被执行时为模板变量赋值
函数名称:assign
参数:var: 声明变量名称 字符串
Value: 给该变量赋值 字符串
<{assign var=”title” value=”this is title”}>
$tpl->assign(“title”,”this is title”);
实现自定义函数有两种:
1.注册自定义函数(3.*版本不支持)
$tpl->register_function(“模板文件中的函数名”,”php中的函数名”)
2. 注册块
$tpl->register_block(“模板文件中的块名”,”php中的函数名”)
自定义函数整理
Counter
<{counter start=0 skip=2 print=false}>
<{counter}<br>
<{counter}>
OUTPUT
2、4