tp3.2 前端截取字符串

在Common目录中建立 function.php

<?php
function subtext($text, $length)
{
    if(mb_strlen($text, 'utf8') > $length) 
    return mb_substr($text, 0, $length, 'utf8').'...';
    return $text;
}

{$vo.goods_name|subtext=10}

调用方法传参数

 

posted @ 2018-04-17 15:16  phpwyl  阅读(927)  评论(0编辑  收藏  举报