Php string length function. 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, below is my php string length function. in php, there are two function tests of string length: one is strlen, the other is supported by the first one before mb_strlen, and 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 ):
Http://www.bkjia.com/PHPjc/445409.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445409.htmlTechArticlephp string length function, in php test string length function has two, one is strlen, the other is mb_strlen before the default is supported, the latter needs to enable a plug-in, below I...