PHP string length function, in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, the latter need to open a plug-in, let us introduce the difference between the two functions and application methods.
PHP Tutorial String length function , in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, the latter need to open a plug-in, let us introduce the difference between the two functions and application methods.
PHP strlen () function
Definition and usage
The strlen () function returns the length of the string.
Grammar
strlen (String) parameter description
string is required. Specifies the string to check.
Echo strlen ("www.bkjia.com!");//13
echo strlen ("Chinese!"); /6 Strlen The value is twice times the number of Chinese characters
?>
Attempt to copy Php_mbstring.dll to the%windows% directory
$str = ' understand PHP know strlen and Mb_strlen is the function of the length of the string ';
echo strlen ($STR) '.
'. Mb_strlen ($str, ' utf-8 ');
?>
Running the above code, the return value is as follows:
66
34
Understand PHP know Strlen and Mb_strlen is the function of the length of the string, but for some beginners, if you do not read the manual, it may not be clear that the difference.
First look at this piece of code (the prerequisite is: Character encoding is utf-8):
http://www.bkjia.com/PHPjc/445409.html www.bkjia.com true http://www.bkjia.com/PHPjc/445409.html techarticle php string length function, in PHP test string length function has two, one is strlen, the other is Mb_strlen before a default is supported, after a need to open a plugin, below I ...