What are the potential pitfalls of using strlen() and substr_count() functions to determine the number of characters in a message for pagination in PHP?

Using strlen() and substr_count() functions to determine the number of characters in a message for pagination in PHP can be problematic because these functions count bytes, not characters. This can lead to incorrect character counts, especially when dealing with multi-byte characters like emojis or accented characters. To accurately count characters, it's recommended to use mb_strlen() function with the appropriate character encoding specified.

// Correct way to count characters in a message for pagination
$message = "Hello, 😊";
$charCount = mb_strlen($message, 'UTF-8');
echo $charCount; // Output: 7