What are the potential pitfalls of using strtoupper() function for case-insensitive string comparison in PHP?

Using strtoupper() for case-insensitive string comparison in PHP can lead to potential pitfalls such as language-specific characters not being converted correctly, which can result in inaccurate comparisons. To solve this issue, it's recommended to use mb_strtoupper() with the 'UTF-8' encoding to ensure proper handling of multibyte characters.

$string1 = "héllo";
$string2 = "HELLO";

if(mb_strtoupper($string1, 'UTF-8') === mb_strtoupper($string2, 'UTF-8')) {
    echo "Strings are equal";
} else {
    echo "Strings are not equal";
}