strlen() function in PHP


The strlen() function is used to get the string length. It returns the length of the string on success. If the string is empty, 0 is returned.

Syntax

strlen(str)

Parameters

  • str − The string for which we want the length.

Return

The strlen() function returns the length of the string on success. If the string is empty, 0 is returned.

Example

The following is an example −

 Live Demo

<?php
   echo strlen("Tom Hanks!");
?>

Output

The following is the output −

10

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Dec-2019

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements