We are using 1. Make sure that the php_mbstring.dll file exists in your Windows/system32 directory. If not, just export the file to Windows/system32 from the extensions directory of your Php installation directory.
2. In the windows directory, find php. ini and open the editor. Search for mbstring. dll. Find; extension = php_mbstring.dll and remove the number; so that the mb_substr function will take effect.
The PHP mb_substr function can also intercept the string length. The following example shows the differences:
- <? Php
- $ Str = 'so that my string will not contain garbled characters ^_^ ';
- Echo "mb_substr:". mb_substr ($ str, 0,7, 'utf-8 ');
- // Result:
- Echo "<br> ";
- Echo "mb_strcut:". mb_strcut ($ str, 0,6, 'utf-8 ');
- // Result:
- ?>
-
From the above example, we can see that the PHP mb_substr function is to split characters by words, while the mb_strcut function is to split characters by byte, but it does not produce half a character.