In this post we will be creating a PHP script that will return the current URL, to do this we will be using the ‘$_SERVER’ variable which contains server and execution environment information
The ‘$_SERVER’ is an array and in this post we will be retrieving the ‘REQUEST_URI’ item, see the snippet of code below for how this is done.
<?php
$URL = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $URL;
?>