The strlen Function

The strlen function returns the length of a string (the number of characters in the string). It works correctly only with Latin characters (single-byte characters).

Syntax

phpstrlen(string $string): int

Example

In this example, the function will return the length of the string 'abcde':

php<?php
  echo strlen('abcde');
?>

Code execution result:

php5

See Also

  • the count function,
    which returns the length of an array