Let's take a look at the following examples:
/* Define data */
...Char * msg1 = "testtest ";Char * msg2 = "test ";Int Len = 20, T = 1;...
1 -----> If (strlen (msg2)> = strlen (msg1)... // right
2 -----> If (strlen (msg2)-strlen (msg1)> = 0)..
We know that to judge the string length in php, we only need to use the strlen () and mb_strlen () functions, but it is not as simple as we think, especially when it comes to a mix of Chinese and English, the above functions are a little inadequate.
Many programmers like to use strlen () Mb_strlen () These functions when judging the length of a string, although they have always been a professional test string length, but they do not know Strlen () Mb_strlen () These functions are not optimal.
Php performance optimization: using isset () to determine the string length is faster than strlen. How can I determine the length of a string in php? Many people think of strlen () mb_strlen () functions first. However, in terms of program
PHP Performance Optimizations: Use Isset () to determine string length faster than strlen ()
How to determine the length of a string in PHP?
The first thing many people think about is strlen () Mb_strlen () these functions.
But in terms of program
The strlen () function can be used to determine the character length in a simple fuzzy way. for example, if you use different Chinese characters and pinyin or encoding, the strlen () function is used to calculate different values, next I will
How can I determine the length of a string in php? Many people think of strlen () mb_strlen () functions first. However, in terms of program performance, these two functions are not optimal in determining the length of a string, although they are
The strlen () PHPstrlen () function defines and uses the strlen () function to return the length of the string. Syntax strlen (string) parameter: string description: required. Specifies the string to be checked. The code is as follows... strlen
In some Web site registration or other activities, we need users to submit some information, for this information will have certain requirements, such as user registration information Some of the limit length can not be less than how much. Here we
strlen functionSyntax: strlen (String)Definition and Usage: the strlen () function returns the length of a string.substr functionSyntax: substr (string,start,length)Definition and Usage: the substr () function returns part of a string.Parameter
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.