Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strlen() Function

PHP strlen() Function

PHP String Reference Manual PHP String Reference Manual

Example

The function returns the length of the string "Hello":

Run Example »


Definition and Usage

The strlen() function returns the length of a string; for Chinese strings use the mb_strlen() function..


Syntax

strlen(

string

)

Parameters Description
string Required. Specifies the string to check.

Technical Details

Return Value: Returns the length of the string on success, or 0 if the string is empty.
PHP Version: 4+
Changelog: Before PHP 5.3.0, this function treated an array as a string Array, which returned a string of length 5 and produced an E_NOTICE level error.

More examples

Example 1

Return the length of the string "Hello World":

Run Example »


PHP String Reference Manual PHP String Reference Manual