Showing posts with label How to get URL of current page in PHP. Show all posts
Showing posts with label How to get URL of current page in PHP. Show all posts

Wednesday 8 April 2015

How to Get the Current Page URL in PHP

How to Get the Current Page URL in PHP

 $CurrentURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$CurrentURL .= "s";}
 $CurrentURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $CurrentURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $CurrentURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }

 echo $CurrentURL;