If you've ever wanted to find the complete current URL of the page you are on using PHP, it's easy using PHP's built in $_SERVER global variables.


To break it down, we start with a string writing the "http://".

We then use the period (.) character to concatenate on the server name. $SERVER['HTTPHOST'] returns the name of the server. e.g. 'localhost' or 'www.blakes-site.co.uk'.

Finally we concatenate on $SERVER['REQUESTURI'] using the period character again. Request URI returns the current page you are accessing on the server e.g. '/blog/view.php'

To show a URL without the 'http://', for simpler presentation simply don't add this string at the start.