Home > php教程 > php手册 > 使用php自带的多字节处理函数来处理中文,最佳方法

使用php自带的多字节处理函数来处理中文,最佳方法

WBOY
Release: 2016-06-13 11:15:50
Original
908 people have browsed it

  echo "

__________________________

";
$string="242432反对感是456,,犯得上广泛大使馆地方7890abc";
$mb_strlen=mb_strlen($string);
$len=20;
echo $string."

";
echo "总长为:".($mb_strlen+1)."

";
echo "截取数:".$len."

";
for($i=1;$i if($i>$len){
echo $i." ".mb_substr($string,$i)."…
";
continue;
}
echo $i." ".mb_substr($string,$i)."
";
}
?>
参看PHP的Multi-Byte String Functions,
(1)编译时使用--enable-mbstring=cn
(2)修改/usr/local/lib/php.inc
default_charset = "zh-cn"
mbstring.language = zh-cn
mbstring.internal_encoding =zh-cn
Everthing I do, I do it for you!
My linux!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template