0
When working with the Unicode character set, use the corresponding function instead of the native string function. For example, if a file is encoded as UTF-8 PHP code, if the strlen() function is wrong, use the mb_strlen() function instead.
If you use substr to intercept Chinese characters, garbled characters will appear, because substr is intercepted in bytes. That is, UTF-8 encoded Chinese, using substr interception, will only intercept 1/3 Chinese, of course, garbled. When UTF-8 is encoded, a Chinese character is 3 bytes. Similarly, different languages in other countries will produce multi-byte strings, so we use mb_strlen() to handle them.