测试源码如下

header("Content-type: text/html; charset=utf-8");
echo '
'; echo "ascii ", strlen('hello'); //ascii echo '
'; echo '
'; function strlentest($str) { echo '
'; echo $str, ":"; echo '
'; echo "utf8 ", strlen($str); //utf8 echo '
'; echo "gbk ", strlen(iconv('utf-8', 'GBK', $str)); //gbk echo '
'; echo "gb2312 ", strlen(iconv('utf-8', 'gb2312', $str)); //gb2312 echo '
'; } $str = "中国人"; strlentest($str); $str = "A人1"; strlentest($str); $str = "AAA"; strlentest($str); $str = "111"; strlentest($str);

结论: 自己总结吧

标签: utf8, gbk, gb2312

添加新评论