- 论坛徽章:
- 0
|
[From] http://club.phpe.net/
$tpl=new smarty;
function test($pararm,$smarty)
{
extract $pararm;
$a=array(1,1,2,4,4);
return $a
}
$tpl->register_function('test','test');
----------------
模板
函数返回是一数组,模版中怎么显示它呢?
==========================
1 $tpl =& new smarty();
2 function test($pararm, & $smarty)
3 {
4 $varname = $param['var'];
5 $out = array(1, 2, 3, 4);
6 $smarty->assign($varname, $out);
7 }
8
9 $tpl->register_function('test','test');
10
11
12 // tpl.html
13
14 {test var="my_var"}
15 {section name="i" loop=$my_var}
16 {$my_var}
17 {/section}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13329/showart_161345.html |
|