// 首先自定義一個函數
//tpl 調用形式<{hsp times="4" size="5" con="hello world" color="red"}>
function test1($args){
$str="";
for($i=0;$i<$args['times'];$i++){
$str.="<font color=' " .$args['color']. " 'size=' " .$args['size']. " '>".$args['con']."</font>"
}
retrun $str;
}
//自定義一個函數過後要經過註冊才能使用
$smarty->register_function("fengtansong","test1");
//指定模板顯示結果
$smarty->display("test1.tpl");
//test1.tpl模板測試
<h1>這裏測試自定義模板的使用</h1>
<{fngtansong times="20" con="測試自定義模板" color="red" size="10" }>