w3resource

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:

<?php 
$string_name = 'Welcome to w3resource.com';
echo strlen($string_name)."<br>";
$string_name = ' Welcome to w3resource.com  ';
echo strlen($string_name)."<br>";
?>

Output:

25
28

View the example in the browser

See also

PHP Function Reference

Previous: stripos
Next: strnatcmp



PHP: Tips of the Day

PHP: Where is PHP.ini in Mac OS X Lion? Thought it was in /usr/local/php5/lib

You should find it in /private/etc if it exists, otherwise:

sudo cp /private/etc/php.ini.default /private/etc/php.ini

Ref : https://bit.ly/3nYzEyI