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}

调用方法传参数

原文地址:https://www.cnblogs.com/phpwyl/p/8866856.html