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.


echo strlen("Learn PHP");


The output of the above code will be:


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


$str="Learn PHP";


echo $length;

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