Home  >  Article  >  Backend Development  >  Solution to the problem of intercepting garbled Chinese characters in PHP Application of mb_substr function_PHP tutorial

Solution to the problem of intercepting garbled Chinese characters in PHP Application of mb_substr function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:53:21637browse

First of all
1. Make sure you have the file php_mbstring.dll under 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 the length of the string. Let’s see the difference in the following example:

Copy the code The code is as follows:

$str = 'This way my string will not be garbled^_^';

echo "mb_substr:" . mb_substr($str, 0, 7, 'utf-8');
//Result: In this way, my words
echo "
";

echo "mb_strcut:" . mb_strcut($ str, 0, 6, 'utf-8');
//Result: like this
?>


As can be seen from the above example, mb_substr is Words are used to split characters, while mb_strcut is used to split characters by bytes, but neither will produce half a character.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318741.htmlTechArticleFirst 1. Make sure you have the file php_mbstring.dll under Windows/system32. If not, go to your Php installation directory Copy extensions into Windows/system32. 2. Find php.i...
in the windows directory
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