$str = "中文字及english測試"; echo strlen($str) . "
"; echo mb_strlen($str, 'UTF-8') . "
"; echo mb_strlen($str, 'UTF8') . "
"; echo mb_strwidth($str, 'UTF-8') . "
"; echo mb_substr($str, 2, 4, 'UTF-8') . "
";
Result:
25
13
13
19
字及en