Two small php problems encountered in the company _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
I encountered two small php problems in my company. 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 encountered two small php problems in the company. close up the problem so that it can be solved 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.

Audit. sleep (10); if it is not placed in the for loop, it will continue to be executed under the process, rather than waiting for. mb_strlen...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.