strlen()

The strlen() method returns the number of bytes in a given string.

Syntax

strlen(string);

The string can either be a literal sequence of characters surrounded by quotes or a variable that refers to such a sequence.

Codebyte Example

The following example showcases the two ways of using the strlen() method:

Code
Output
Loading...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn PHP on Codecademy