+

PHP Strlen () function

Syntax:
strlen($string)
Parameters:The strlen() function takes only one parameter $string, which is required. This parameter represents a string, the length of which must be returned.Returned value:The function returns the length of the string $, including all spaces and special characters. Examples:
Input: "abc" Output: 3 Input: "chetna;" Output: 10 Explanation : `` is considered as a single character as it is an escape sequence. Input: "engineer for engineer" Output: 15
The following programs illustrate the strlen() function in PHP:Program 1:The program below demonstrates the use of the function strlen() in PHP. < tbody> // PHP search engine // the length of the given string $str = "engineer for engineer" ; // prints line length // includes space echo strlen ( $str ); ?> Output:
15
Program 2:The program below demonstrates the use of the strlen() function in PHP, where a string has special characters and escape sequences. // PHP search engine // the length of a given string that has // special characters $str = "chetna;" ; // here ` / n ` counts 1 echo strlen ( $str ); ?> Output:
10
Link :
http: / /php.net/manual/en/function.strlen.php
Get Solution for free from DataCamp guru