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'];


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

Share This Post

Related Articles

© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie