Php String Length function. In php, two functions are used to test the string length. One is strlen, and the other is supported by the previous one before mb_strlen by default. The other one needs to enable a plug-in, next we will introduce the differences between the two functions and the application methods.
Php tutorial String Length FunctionIn php, two functions are used to test the string length. One is strlen, and the other is supported by the previous one by default. The other one needs to enable a plug-in, next we will introduce the differences between the two functions and the application methods.
Php strlen () function
Definition and usage
The strlen () function returns the length of the string.
Syntax
Strlen (string) parameter description
String is required. Specifies the string to be checked.
Echo strlen ("www.bkjia.com! "); // 13
Echo strlen ("Chinese! "); // The value obtained by strlen 6 is twice the number of Chinese Characters
?>
Try to copy php_mbstring.dll to the % windows % directory
$ Str = 'all php users know that strlen and mb_strlen are functions for string lengths ';
Echo strlen ($ str )'.
'. Mb_strlen ($ str, 'utf-8 ');
?>
Run the preceding code and return the following values:
66
34
All php users know that strlen and mb_strlen are functions used to evaluate the string length. However, for some beginners, if they do not read the manual, they may not know the difference.
Let's take a look at this piece of code first (the prerequisite is: the character encoding is UTF-8 ):