How can you check if a URL contains a hash symbol in PHP?

To check if a URL contains a hash symbol in PHP, you can use the strpos() function to search for the "#" character within the URL string. If the function returns a value greater than or equal to 0, then the hash symbol is present in the URL.

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

if (strpos($url, '#') !== false) {
    echo "URL contains a hash symbol.";
} else {
    echo "URL does not contain a hash symbol.";
}