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() fucntion accepts only one parameter $string which is mandatory. This parameter represents the string whose length is needed to be returned.
Return Value: The fucntion returns the length of the $string including all the whitespaces and special characters.
Input : "abc" Output : 3 Input : "\n chetna ;" Output : 10 Explanation : '\n' is considered as a single character as it is an escape sequence. Input : "geeks for geeks" Output :15
Below programs illustrate the strlen() function in PHP:
Program 1: The below program demonstrates the use of strlen() function in PHP.
Program 2: The below program demonstrates the use of strlen() function in PHP where the string has special characters and escape sequences.
- PHP | Ds\Map first() Function
- p5.js | tan() function
- D3.js | d3.lab() Function
- D3.js | d3.map.set() Function
- p5.js | cos() function
- PHP Ds\Map sum() Function
- p5.js | log() function
- PHP | max( ) Function
- D3.js | d3.hcl() Function
- p5.js | sin() function
- D3.js | d3.min() function
- PHP | pos() Function
- PHP | key() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.