* 1.strlen($str)
* 2.mb_strlen($str, $encoding)
$siteName = 'php中文网';
//Get the internal character encoding set
$encoding = mb_internal_encoding(); echo '内部字符编码集: ',$encoding,'
';
/ /1.strlen($str): Get the string length represented by bytes
//In utf8 mode, a Chinese character is represented by three bytes
echo strlen($siteName),'
';
//2.mb_strlen ($str, $encoding): Get the length represented by the number of characters
echo mb_strlen($siteName, $encoding),'
';
//Omit the second parameter, the system default character encoding set will be used, which is currently utf-8
echo mb_strlen($siteName),'
'; //返回值不变