We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

tylerhall on 05/25/07


Tagged

url php textmate server Complete full


Versions (?)


Who likes this?

11 people have marked this snippet as a favorite

basicmagic
bitcrumb
vali29
hudge
benrasmusen
Abe
Steffen82
sindrom
romanos
HeroDoug
oriolfb


Get Full URL


Published in: PHP 


Returns the full URL of the current page - including any query parameters.

  1. function full_url()
  2. {
  3. $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
  4. $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
  5. $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
  6. return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
  7. }

Report this snippet 

You need to login to post a comment.