PHP strlen() Function

Definition

The strlen() function takes a string and returns the number of characters in it.

Syntax

PHP strlen() Function has the following syntax.

int strlen ( string str )

Parameter

str is the string value to check.

Return

PHP strlen() Function returns the length of a string.

Example

Get the string length


<?PHP
print strlen("Foo") . "\n"; 
print strlen("Hi from java2s.com!") . "\n"; 
?>

For multibyte strings we should be measured with mb_strlen().

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions