Two minor problems with PHP encountered in the company_PHP tutorial

WBOY
Release: 2016-07-13 17:44:33
Original
945 people have browsed it

I encountered two small php problems in the company. I wrote them down so that I can see how they can be solved in the future.
sleep(10); If it is not placed in the for loop, the execution will continue below the process without waiting. .

mb_strlen(val,"utf-8");
It’s still a question about Chinese. PHP's built-in string length function strlen cannot handle Chinese strings correctly. All it gets is the number of
bytes occupied by the string. For the Chinese encoding of GB2312, the value obtained by strlen is 2 times the number of Chinese characters, while for UTF-8 encoded Chinese, the difference is 3 times
(under UTF-8 encoding, one Chinese character occupies 3 characters Festival).
Using the mb_strlen function can better solve this problem. The usage of mb_strlen is similar to strlen, except that it has a second optional parameter for
to specify the character encoding. For example, to get the UTF-8 string $str length, you can use mb_strlen($str,UTF-8). If the second parameter is omitted,
will use PHP's internal encoding. The internal encoding can be obtained through the mb_internal_encoding() function. It should be noted that mb_strlen is not a
PHP core function. Before using it, you need to make sure that php_mbstring.dll is loaded in php.ini, that is, make sure that the line "extension=php_mbstring.dll"
exists and is not commented out. , otherwise the problem of undefined function will occur.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478752.htmlTechArticleI encountered two small php problems in the company. I wrote them down so that I can see how they can be solved in the future. sleep(10) ;If it is not placed inside the for loop, execution will continue below the process without waiting. mb_strlen...
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