Php 修剪标题wordpress时,strlen()显示错误字符

Php 修剪标题wordpress时,strlen()显示错误字符,php,wordpress,character-encoding,char,strlen,Php,Wordpress,Character Encoding,Char,Strlen,斯特伦在标题末尾显示错误字符是“其显示”�..." 下面是我的代码: <?php $title = the_title('', '', false); $title = (strlen($title)<60) ? $title : substr($title,0,50)."..."; echo $title; <?php endforeach; ?> 对于unicode字符,您需要使用mb_strlen()和mb_substr() 将上面的行改写为 $title =

斯特伦在标题末尾显示错误字符是“其显示”�..."

下面是我的代码:

<?php $title = the_title('', '', false); 
$title = (strlen($title)<60) ? $title : substr($title,0,50)."...";
echo $title;
<?php endforeach; ?>

对于unicode字符,您需要使用
mb_strlen()
mb_substr()

将上面的行改写为

$title = (mb_strlen($title,'utf-8')<60) ? $title : mb_substr($title,0,50,'utf-8')."...";

$title=(mb_strlen($title,'utf-8')我收到了这个错误:警告:strlen()只需要1个参数,2个参数在/home/oranews/public\u html/wp content/themes/oranews/loop-single.php第44I行我说
mb_strlen()
为什么你还在使用
strlen()
?Iam在我的服务器上安装mbstring我希望这会有帮助:)之后如果有任何问题,请告诉我。