What are the potential pitfalls of using $_SERVER['HTTP_REFERER'] to get the URL in PHP?

Using $_SERVER['HTTP_REFERER'] to get the URL in PHP can be unreliable as it relies on the client's browser to send the referrer information. This can be easily manipulated or stripped by the user's browser or any intermediate proxies. To ensure a more reliable way of getting the current URL, it's recommended to use other methods like using $_SERVER['REQUEST_URI'] along with the server's hostname.

$currentURL = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $currentURL;