美文网首页
TP5的字符串截取超过字符...显示

TP5的字符串截取超过字符...显示

作者: zhaoxiaohui520 | 来源:发表于2020-04-25 11:38 被阅读0次
    在公共的common.php中
    function subtext($text, $length)
    
    {
    
    if(mb_strlen($text, ‘utf8’) > $length)
    
    return mb_substr($text,0,$length,’utf8′).’ …’;
    
    return $text;
    
    }
    
    在模版中调用则:
    {$tops.title | subtext=18}
    

    相关文章

      网友评论

          本文标题:TP5的字符串截取超过字符...显示

          本文链接:https://www.haomeiwen.com/subject/gpihwhtx.html