Home >Backend Development >PHP Tutorial >PHP method to intercept Chinese string (no garbled characters)
The mb_substr method has one more parameter than substr, which is used to specify the string encoding. 2. Example of intercepting Chinese string using UTF-8 encoding.
Tips: Mixing Chinese and English is no problem at all. Attention, pay attention to the encoding of the php file when using it, and the encoding when displaying the web page. To use this mb_substr method, you need to know the encoding of the string in advance. If you don't know the encoding, you can use mb_check_encoding provided by the mbstring library to check the string encoding, but it is not perfect yet. |