PHP strlen

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : strlen() function

Description

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 :

  1. $string_name = 'Welcome to w3resource.com';  

  2. echo strlen($string_name)."
    ";  

  3. $string_name = ' Welcome to w3resource.com  ';  

  4. echo strlen($string_name)."
    ";  

  5. ?>  

Output :

25
28