标签:
php内置函数 1. iconv iconv_set_encoding(‘internal_encoding‘, ‘UTF-8‘); $str; //字符串的声明 $num=iconv_strlen($str); $str_substr=iconv_substr($str, , ); 2. mb mb_internal_encoding(‘UTF-8‘); $str; $num=mb_substr($sub , , ) 测试代码 header(‘Content-Type: text/html;charset=utf-8‘); //iconv_set_encoding(‘internal_encoding‘, ‘UTF-8‘); $name="实验文字!实验文字!实验文字!实验文字!"; //echo $name; //$num=iconv_strlen($name); //$name=iconv_substr($name, 6, 2); //echo $name; //echo $num; mb_internal_encoding(‘UTF-8‘); $num = mb_strlen($name); $name = mb_substr($name, 5); echo "<br>".$name; echo $num;
标签:
原文地址:http://www.cnblogs.com/xiashuo-he/p/4270825.html