How can PHP be used to determine the current URL of a file?

To determine the current URL of a file in PHP, you can use the $_SERVER['REQUEST_URI'] variable. This variable contains the URI of the current request, including the query string if present. By accessing this variable, you can retrieve the current URL of the file being executed.

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