In this tutorial we will learn How To Find String Length in PHP. PHP strlen() function can be used to find the length of string or number of characters present in string.
Table of Contents
Using strlen() Function
We can simply use strlen() Function to find string length in PHP.
strlen() Function is a built-in PHP function which returns the length of string or number of characters present in the string.
Take a look at the code given below.
<?php
$string = 'HowToCodeSchool.com';
$stringLength = strlen($string);
echo $stringLength;
?>
$stringLength variable contains the length of the original string.
strlen() Function is supported in PHP 4+ versions, so you can use it anywhere.
Output
19