What is the best way to retrieve the current Internet address in PHP for use in a script that will be downloadable?

To retrieve the current Internet address in PHP, you can use the $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] variables to get the hostname and URI of the current request. You can then concatenate these variables to get the full Internet address. This is useful when creating scripts that need to reference the current URL dynamically.

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