In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "php how to check Chinese character string has several characters", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php how to check Chinese character string has several characters" article.
In php, you can use the mb_strlen () function to check how many characters there are in the Chinese character string. The syntax is "strlen (string," character coding ")", which can accurately return the number of characters in the Chinese character string; this function can deal with Chinese characters by setting the character encoding, so that Chinese characters, English, numbers, etc., all occupy only one character length.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
There are two functions commonly used in PHP to calculate the length of a string, which are the strlen () and mb_strlen () functions. When dealing with all-English strings, the two functions have the same effect, while when dealing with mixed or pure Chinese strings, the two functions will have some differences.
Strlen () cannot accurately evaluate strings in both English and Chinese or pure Chinese, while mb_strlen () can.
Therefore, to check how many characters a Chinese character string has, you need to use the mb_strlen () function.
Php mb_strlen () function
The mb_strlen () function returns the length of the string, that is, counting the number of characters in the string.
Syntax:
Strlen (string, "character encoding")
This function can return the corresponding number of characters by setting the character encoding, which well deals with the length of the Chinese string.
In the mb_strlen () function, by setting the character encoding, both Chinese characters, numbers, decimal points, underscores and spaces occupy only one character length.
Return value: returns the length of the string if successful, and 0 if the string is empty.
Example: check how many characters are in the Chinese character string
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.