How to Find String Length in PHP - strlen() Function
PHP String FunctionsThe strlen() function returns the length of a given string. It returns 0 if the string is empty.
Syntax
strlen(string $string)
Parameter
- string (Required) - Specifies the string to check
Example
$str = 'abcdef';
echo strlen($str);
The output of the above example will be 6.
The function strlen() returns the number of bytes rather than the number of characters in a string. So, if there are characters that take more than 1 byte, you may not get the actual length.