前端调用PHP函数的方式

html_entity_decode()

<div class="rxzcB fl">{$service.introduction|html_entity_decode}div>

其中的service.introductionhtmlPHPhtmlentitydecodeservice.introduction中的换行符br换行输出。

mb_substr()

这是一个字符串截取函数,可以截取指定长度的字符串。例如:

{$vo.publish_time|mb_substr=0,10,'utf-8'}

从后台传来的数据$vo.publish_time是一个精确到秒的时间值,格式如2017-09-12 12:58,而前台显示只需要将时间精确到日即可。调用方式如上例所示。

substr_replace

字符串替换函数,可以将制定位的字符串替换掉。如下例,就是讲手机号码的中间四位替换成“*”。

{$vo.author | substr_replace='****',3,4}

你可能感兴趣的:(html)