php string length

Posted by Paidboom - 1 year ago

php string length

The strlen() function returns the length of a string.

<?php
echo strlen("Hello");
?>

How to find string length in PHP?

<?php
$str1 = 'Hello world!';
echo strlen($str1); // Outputs: 12
echo "<br>";

$str2 = ' Hello    world! ';
echo strlen($str2); // Outputs: 17
?>