PHP Server – Get the current URL

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.

echo $URL;

Leave a Reply