How can the $_SERVER['REQUEST_URI'] variable be utilized to determine the active URL in a PHP script?

To determine the active URL in a PHP script, you can use the $_SERVER['REQUEST_URI'] variable. This variable contains the URI of the current request, including query parameters if present. By accessing this variable, you can easily determine the active URL being accessed by the user.

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