PHP strlen

strlen()-To find the length of a string

To find the length of a string, we use a function strlen(). Let’s use this function to find the length of a string.

<?php

echo strlen("Learn PHP");

?>

The output of the above code will be:

9

Alternatively, we can write the PHP script like the way below. The output will be the same as above.

<?php

$str="Learn PHP";

$length=strlen($str);

echo $length;

?>
If you have found my website useful, please consider buying me a coffee below 😉