PHP strlen() Function
Example
The function returns the length of the string "Shanghai":
<?php echo strlen("Shanghai"); ?>
Definition and Usage
The strlen() function returns the length of the string.
Syntax
strlen(string)
Parameter | Description |
---|---|
string | Required. Specifies the string to be checked. |
Technical Details
Return Value: | Returns the length of the string if successful, and 0 if the string is empty. |
PHP Version: | 4+ |
Update Log: | Before PHP 5.3.0, the function treated the array as a string Array, so it returned a string of length 5 and generated an E_NOTICE level error. |
More Examples
Example 1
Return the length of the string "I love Shanghai!":
<?php echo strlen("I love Shanghai!"); ?>