What are the potential pitfalls of using PHP to extract URLs from the $_SERVER array?

One potential pitfall of using PHP to extract URLs from the $_SERVER array is that the values may not always be reliable or consistent across different server configurations. To ensure accurate extraction of URLs, it is recommended to use the PHP built-in function `filter_input()` with the `FILTER_SANITIZE_URL` filter option. This will help sanitize and validate the URL before extracting it from the $_SERVER array.

$url = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);
if($url){
    echo "URL: " . $url;
} else {
    echo "URL not found";
}