String Functions

PHP strlen() Function

Topic: PHP String ReferencePrev|Next


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

The following table summarizes the technical details of this function.

Return Value: Returns the length of the string on success, and 0 if the string is empty.
Version: PHP 4+


The basic syntax of the strlen() function is given with:


The following example shows the strlen() function in action.

// Sample string
$str = "Hello World!";

// Getting the string length
echo strlen($str);


The strlen() function accepts the following parameters.

Parameter Description
string Required. Specifies the string to check for length.
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties