/var/Widget/Base/Contents.php /** *Output Title * *@ param integer $length *@ param string $trim truncate suffix */ public function title(int $length = 0, string $trim = '...') { $title = Contents::pluginHandle()->trigger($plugged)->title($this->title, $this); if (!$ plugged) { echo $length > 0 ? Common::subStr($this->title, 0, $length, $trim) : $this->title; } else { echo $title; } }
/var/Typecho/Common.php
/** *Wide string truncation function * *@ param string $str The string to be intercepted *@ param integer $start *@ param integer $length *@ param string $trim Truncation identifier after truncation * * @return string */ public static function subStr(string $str, int $start, int $length, string $trim = "... "): string { if (! strlen($str)) { return ''; } $iLength = self::strLen($str) - $start; $tLength = $length < $iLength ? ($length - self::strLen($trim)) : $length; $str = mb_substr($str, $start, $tLength, 'UTF-8'); return $length < $iLength ? ($str . $trim) : $str; } /** *Get wide string length function * *@ param string $str needs to get a string of length * @return integer */ public static function strLen(string $str): int { return mb_strlen($str, 'UTF-8'); }
conclusion
<? php $this->title('1',''); ?>
]]>