Home  >  Article  >  Backend Development  >  Application of mb_substr function to solve the problem of garbled Chinese characters intercepted by PHP

Application of mb_substr function to solve the problem of garbled Chinese characters intercepted by PHP

PHP中文网
PHP中文网Original
2017-06-10 10:05:491040browse

1. First, make sure you have the file php_mbstring.dll in Windows/system32. If not, copy it from your Php installation directory extensions into Windows/system32.
2. Find php.ini in the windows directory, open it for editing, search for mbstring.dll, find
;extension=php_mbstring.dll, and remove the ; sign in front, so that the mb_substr function can take effect. The mb_strcut function can also intercept strings. Length, let’s see the difference in detail in the following example:

The code is as follows:

As can be seen from the above example, mb_substr splits characters by words, while mb_strcut splits characters by bytes, but both There will be no half-character phenomenon.

The above introduces the application of the mb_substr function, a solution to the problem of intercepting garbled Chinese characters in PHP. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn