What are the potential pitfalls of using stristr() in PHP for string comparison and how can they be mitigated?

Potential pitfalls of using stristr() in PHP for string comparison include case sensitivity and unexpected matches due to partial string matches. To mitigate these issues, you can use the strtolower() function to convert both strings to lowercase before comparing them.

$string1 = "Hello World";
$string2 = "hello world";

if (strtolower($string1) === strtolower($string2)) {
    echo "Strings are equal.";
} else {
    echo "Strings are not equal.";
}