Home >Backend Development >PHP Tutorial >How to use php strlen function
The strlen function is a built-in function in PHP. The syntax is strlen(string), which is used to obtain the length of a string. This function calculates the length of a string, including all spaces and special characters; it takes the given string as an argument and returns its length.
php How to use strlen() function?
php strlen() function returns the length of the string
Syntax:
strlen(string)
Parameters:
string: required. Specifies the string to check.
Return value: Returns the length of the string.
php strlen() function example 1
<?php echo strlen("I love php!"); ?>
Output:
11
php strlen() function example 2
<?php echo strlen("i study php at php.cn"); ?>
Output:
21
This article is an introduction to the PHP strlen function. I hope it will be helpful to friends in need!
The above is the detailed content of How to use php strlen function. For more information, please follow other related articles on the PHP Chinese website!