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

PHP中文网
Release: 2023-02-28 21:16:02
Original
1038 people have browsed it

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:

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!