How to find String Length in PHP?
Use the strlen() function. It returns the length of a string. Spaces and special characters are counted too.
<?php
echo strlen("Hello world!");
?>
Output:
Tutorials Class - Output Window
12
strlen() counts bytes, so for non-English text (like Hindi) or emoji use mb_strlen(). See strlen() vs mb_strlen().
Learn more about the similar topics:
| Tutorials |
|---|
| PHP String Handling |
| PHP explode() Function |
| PHP strpos() Function |
| PHP implode() Function |