strlen() function in PHP

PHPProgrammingServer Side Programming

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
raja
Published on 17-Oct-2018 16:13:06
Advertisements