How can the $_SERVER array be used to gather information about the current URL in PHP?

To gather information about the current URL in PHP, you can use the `$_SERVER` array which contains server and execution environment information. Specifically, you can access the 'REQUEST_URI' key in the `$_SERVER` array to get the current URL. This key contains the URI which was given in order to access the page.

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