PHP: strlen() function
PHP: Get string length
The strlen() function is used to return the length of a string.
Version:
(PHP 4 and above)
Syntax:
strlen(string_name)
Parameter:
| Name | Description | Required / Optional  | 
Type | 
|---|---|---|---|
| string_name | The specified string. | Required | String | 
Return value:
The length of the string on success, and 0 for an empty string.
Value Type: Integer.
Example:
<?php 
$string_name = 'Welcome to w3resource.com';
echo strlen($string_name)."<br>";
$string_name = ' Welcome to w3resource.com  ';
echo strlen($string_name)."<br>";
?>
Output:
25 28
View the example in the browser
See also
