PHP strlen() Function

❮ PHP String Reference

Example

Return the length of the string "Hello":

<?php
echo strlen("Hello");
?>
Try it Yourself »

Definition and Usage

The strlen() function returns the length of a string.


Syntax

strlen(string)

Parameter Values

Parameter Description
string Required. Specifies the string to check

Technical Details

Return Value: Returns the length of a string (in bytes) on success, and 0 if the string is empty
PHP Version: 4+

More Examples

Example

Return the length of the string "Hello World":

<?php
echo strlen("Hello world!");
?>
Try it Yourself »

❮ PHP String Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.