English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Character String Function Manual
The strlen() function is used to return the length of a string, and the handling of Chinese character strings uses mb_strlen() Function
int strlen ( string $string )
It is used to get the length of the string.
Returns the length of the string string if successful; if string is empty, returns 0.
Serial Number | Parameters and Description |
---|---|
1 | string Required. The string that needs to be calculated for length. |
Try the following example to calculate the length of a string:
<?php //Calculate the length of a string $input = 'sairam'12345'; echo strlen($input); echo '<br>'; //Calculate the length of a string containing spaces $str = ' ab cd '; echo strlen($str); echo '<br>'; //Calculate the length of a string containing special characters or punctuation marks $str = '@abcd$#'; echo strlen($str); ?>Test and see‹/›
Output Result
11 7 7