October 2005
Intermediate to advanced
372 pages
11h 35m
English
strlen()
int strlen ( string str )The strlen()
function takes just one parameter (the string), and returns the number of characters in it:
print strlen("Foo") . "\n"; // 3
print strlen("Goodbye, Perl!") . "\n"; // 14Behind the scenes, strlen() actually counts the number of bytes in your string, as opposed to the number of characters. It is for this reason that multibyte strings should be measured with mb_strlen().