What is the use of strlen () function in php?
View Discussion Show Improve Article Save Article View Discussion Improve Article Save Article 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. Syntax: strlen($string); 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. PHP
Output: 13 Example 2: This example demonstrates the use of the strlen() function where the string has special characters and escape sequences. PHP
Output: 25 Reference: http://php.net/manual/en/function.strlen.php PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. (PHP 4, PHP 5, PHP 7, PHP 8) strlen — Get string length Descriptionstrlen(string Parametersstring The string being measured for length. Return Values The length of the ExamplesExample #1 A strlen() example
Notes
See Also
rm dot nasir at hotmail dot com ¶ 6 years ago
chernyshevsky at hotmail dot com ¶ 18 years ago
joeri at sebrechts dot net ¶ 6 years ago
jasonrohrer at fastmail dot fm ¶ 9 years ago
vcardillo at gmail dot com ¶ 10 years ago
"Length: " . strlen($foo) . " basil at gohar dot us ¶ 12 years ago
= array('one', 'two', 'three'); John ¶ 5 years ago
= 100000000; // 100 million What is the use of strlen () and strpos () functions in PHP?PHP String Functions. How do I get strlen in PHP?Answer: Use the PHP strlen() function
You can simply use the PHP strlen() function to get the length of a string. The strlen() function return the length of the string on success, and 0 if the string is empty.
What is the use of strlen () method in C?strlen() function in c
The strlen() function calculates the length of a given string. The strlen() function is defined in string. h header file. It doesn't count null character '\0'.
What is the use of strpos () function in PHP?strpos in PHP is a built-in function. Its use is to find the first occurrence of a substring in a string or a string inside another string. The function returns an integer value which is the index of the first occurrence of the string.
|