php
Calculate length of a string using strlen() function in php
September 23, 2022
The strlen() function in PHP is used to calculate the length of a string. It takes a string as an argument and returns the number of characters in that string.
<?php
$str_len = strlen("foobar");
echo $str_len;
// -> 6
?>
Output
Output will be : 7
To get the length of a string strlen() function is used in PHP. In the code, we have passed a string which has the value - 'foo bar'. It will return '7' as an output as the string length.
Was this helpful?
Similar Posts