How to find number of characters in a string in PHP

strlen() function is used to find the number of characters in a string of text. It also includes the white spaces inside the string.

<?php
$str1 = 'Welcome to PHP Tutorial';
echo strlen($str1); // Outputs: 23
 
$str2 = '    Welcome to PHP Tutorial ';
echo strlen($str2); // Outputs: 28
?>

Chockalingam