What are the potential pitfalls of using the strlen function in PHP for string manipulation?

Using the strlen function in PHP for string manipulation can lead to potential pitfalls when dealing with multibyte characters. This is because strlen counts bytes, not characters, which can result in incorrect string lengths for multibyte characters like emojis or accented characters. To accurately count the number of characters in a string, you should use mb_strlen instead.

// Using mb_strlen to accurately count the number of characters in a string
$string = "Hello 😊";
$length = mb_strlen($string);
echo $length; // Output: 7