Get current URL in PHP

Sometime, you need to get a current page URL that is shown in the browser address bar. Here is a small code to get the current url.

$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME']
.$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME']
.$_SERVER['REQUEST_URI'];

Bansal Sumit

To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *