In this tutorial, you’ll learn how to get current web page URL from your web browser address bar using PHP script.
To get Current Page URL We can use $_SERVER Environment variables.
if the Website running on standard port (80,443) web site current URL will be,
if the website running under non-standard port, current URL will be,
i am gonna convert this script into standard function :
Useful Environment variables of URL:
$_SERVER[‘HTTP_HOST’] = Host name from the current request.
$_SERVER[‘HTTP’] = Set to a non-empty value if the protocol is HTTP
$_SERVER[‘HTTPS’] = Set to a non-empty value if the protocol is HTTPS
$_SERVER[‘SERVER_PORT’] = Server port. Default is: 80
$_SERVER[‘REQUEST_URI’] = The URI to access this page,For example, ‘/index.php’.
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.