Example 1 — Count Characters in a String
The simplest use: measure a short word.
<?php
$word = "Hello";
echo strlen($word), PHP_EOL; How It Works
- Store a word in a variable.
- Pass it to strlen.
- PHP counts each byte. Here each letter is one byte.
- echo prints the result: 5.

