To get the current page url please check the below php script.
In the below script we define a function named as currentPageURL( ). Then we have created a variable named as $PageURL having value http. Now we are using the PHP superglobal varriable named as $_SERVER[SERVER_PORT]. This variable always return the current port of your server.
Now we are checking if the port number of our server is 80 that indicates that we are using local server. then we can get the server name using variable $_SERVER[SERVER_NAME]and at the same time we can get page url using the variable $_SERVER[REQUEST_URI] and then we can assign easily this value to the defined $PageURL variable.
So now whenever we hot the function then $PageURL returns name of server, port and url. so for displaying this we just call our function when we require.