STRLEN(3) 1 STRLEN(3)
strlen - Get string length
SYNOPSIS
int strlen (string $string)
DESCRIPTION
Returns the length of the given $string.
PARAMETERS
o $string
- The string being measured for length.
RETURN VALUES
The length of the $string on success, and 0 if the $string is empty.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | Prior versions treated arrays as the string |
| | Array, thus returning a string length of 5 and |
| | emitting an E_NOTICE level error. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
A strlen(3) example
<?php
$str = 'abcdef';
echo strlen($str); // 6
$str = ' ab cd ';
echo strlen($str); // 7
?>
NOTES
Note
strlen(3) returns the number of bytes rather than the number of characters in a string.
Note
strlen(3) returns NULL when executed on arrays, and an E_WARNING level error is emitted.
SEE ALSO
count(3), grapheme_strlen(3), iconv_strlen(3), mb_strlen(3).
PHP Documentation Group STRLEN(3)