I encountered two small php problems in my company. I will close them up so that we can solve them in the future. sleep (10); if it is not placed in the for loop, it will continue to be executed below the process, rather than waiting. mb_strlen (val, UTF-8); is still related to Chinese. PHP's built-in string length function strlen cannot properly process Chinese strings. it SyntaxHi
I encountered two small php problems in my company. I will close them up so that we can solve them in the future.
Sleep (10); if it is not placed in the for loop, it will continue to be executed below the process, rather than waiting.
Mb_strlen (val, "UTF-8 ");
Or questions about Chinese. The built-in string length function strlen in PHP cannot properly process Chinese strings. all it produces is what the string occupies.
The number of bytes. For GB2312 Chinese encoding, the strlen value is twice the number of Chinese characters, while for the UTF-8 encoding of Chinese, is three times the difference
(A Chinese character occupies 3 bytes in UTF-8 encoding ).
Using the mb_strlen function can better solve this problem. The usage of mb_strlen is similar to that of strlen, except that it has a second optional parameter
Specifies the character encoding. For example, to get the string $ str length of the UTF-8, you can use mb_strlen ($ str, UTF-8 ). If the second parameter is omitted
PHP internal code is used. The internal encoding can be obtained through the mb_internal_encoding () function. It should be noted that mb_strlen is not
Before using PHP core functions, make sure that php_mbstring.dll is loaded in php. ini to ensure "extension = php_mbstring.dll"
This row does not exist and is not commented out. Otherwise, the problem of undefined functions may occur.