Use PHP to get the string length (strlen, mb_strlen. Strlenintstrlen (stringstr) gets the length of the string specified as a parameter. Because the number of bytes is obtained, the halfwidth text is 1 byte and the fullwidth text is 2 bytes. Parameter: & nbsp; str object [Translation] use PHP to get the string length (strlen, mb_strlen)
Returns the length of a string.
strlenint strlen(string str)
Gets the length of the string specified as a parameter. Because the number of bytes is obtained, the halfwidth text is 1 byte and the fullwidth text is 2 bytes.
Parameters:
Str object string
Return value:
Number of bytes of a string
For the length of halfwidth text and fullwidth text, the following is an example:
strlen('abc') --> 3strlen('あいう') --> 6strlen('abcあいう') --> 9
If the number of bytes is not obtained, but the number of characters is obtained, use the [mb_strlen] function. But the halfwidth text is still full-width text,
All are processed in 1 text.
mb_strlenint mb_strlen(string str [, string encoding])
Parameters:
String object string
Character encoding of the encoding object string
Return value:
Number of characters in a string
The following is a practical test.
PHP TEST
'); Print ($ str1. 'character number of characters'. $ str_character EN1. 'character counts
'); Print ($ str2.' maximum text column length limit comment '. $ str_len2.' maximum comment
'); Print ($ str2. 'maximum number of characters'. $ str_{en2. 'maximum number of characters
');?>
Publish the above file to the WEB server and access it via a browser. The result is as follows.