smarty内置函数、自定义函数

1.把字符串里的d字母替换成h
格式:{'d'|str_replace:'h':$str}; d要查找的字符 h要替换的字符 $str字符串

2.function test($param){
$p1=$param['p1'];
$p2=$param['p2'];
return '参数1:'.$p1.'参数2:'.$p2;
}
以数组形式传给函数里面

$smarty->registerPlugin('function','f_test','test');
function:函数体
f_test:注册到sm后的函数
test:往里注册的函数名

test.html:{f_test p1='abc' p2='dce' }

原文地址:https://www.cnblogs.com/family-626-77/p/5736145.html