What potential pitfalls should I be aware of when searching for a substring within a URL field in PHP?

When searching for a substring within a URL field in PHP, it's important to be aware of potential pitfalls such as case sensitivity, special characters, and encoding issues. To avoid these pitfalls, you can use the `strpos()` function in PHP to perform a case-insensitive search for the substring within the URL.

$url = "https://www.example.com/page";
$substring = "example";

if (strpos(strtolower($url), strtolower($substring)) !== false) {
    echo "Substring found in URL";
} else {
    echo "Substring not found in URL";
}