PHP strlen() Function
In this article, we will see how to get the length of the string using strlen() function in PHP, along with understanding its implementation through the examples.
The strlen() is a built-in function in PHP which returns the length of a given string. It takes a string as a parameter and returns its length. It calculates the length of the string including all the whitespaces and special characters.
Parameters: The strlen() function accepts only one parameter $string which is mandatory. This parameter represents the string whose length is needed to be returned.
Return Value: The function returns the length of the $string including all the whitespaces and special characters.
Below programs illustrate the strlen() function in PHP:
Example 1: The below example demonstrates the use of the strlen() function in PHP.
Example 2: This example demonstrates the use of the strlen() function where the string has special characters and escape sequences.