Thinkphp模板变量调用自定义函数
自定义函数放在Common/function.php中,在模板中使用的格式为{$var|function1|function2=param1,param2,###}
其中:
多个函数用|隔开
param1,param2,###为参数,
###代表变量本身作为参数传递给函数
{$var|strtolower}
{$var|substr=0,3}
{$tel|replaceTel}
函数replaceTel为自定义函数,用*替换手机号码局部
function replaceTel($tel){ return substr_replace($tel, '****', 3, 4); }
浙公网安备 33010602011771号