Posted By

juanrossi on 09/14/10


Tagged

url php variables full


Versions (?)

Full url without variables


 / Published in: PHP
 

Based on http://snipplr.com/view/2734/get-full-url/

  1. <?
  2. function full_url()
  3. {
  4. $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
  5. $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
  6. $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
  7. $address = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
  8. $parseUrl = parse_url(trim($address));
  9. return $parseUrl['scheme'].'://'.$parseUrl['host'].$parseUrl['port'].$parseUrl['path'];
  10. }
  11. ?>

Report this snippet  

You need to login to post a comment.