天天看点

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

在公共的

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}