Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to use strlen() function in PHP?
If you want to get the length of your string word then you should use the strlen() function.
This function is used for getting the length of a string.The strlen() function always returns length of a string when it goes for success and when it goes for empty then it return 0.
strlen() function also counts whitespaces, exclamation marks and new line characters at the end of a string.
Note:-The strlen() function always supports PHP 4+ version.
Syntax of the strlen() function
strlen(string)
string is required parameter and specifies the string to check
you can see below example for better understanding.
exmaple 1:-
<!DOCTYPE html>
<html>
<body>
<?php
echo strlen("Hi mac how are you ?");
?>
</body>
</html>
output will come following
20
Example 2:-
<?php
$a = "abcdef\n";
echo "<p>".strlen($a)."</p>";
?>
Output will come following
7
0 Comment(s)