Posted By

tylerhall on 05/25/07


Tagged

url php textmate server Complete full


Versions (?)

Who likes this?

22 people have marked this snippet as a favorite

basicmagic
bitcrumb
vali29
hudge
benrasmusen
Abe
Steffen82
sindrom
romanos
HeroDoug
oriolfb
nb109
Hollow
exentrich
ignace
galofre
all3n
bobbym245
uilgenstein
mecha
IMPGTX
tux-world


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  

Comments

RSS Icon Subscribe to comments
Posted By: jigishpthakar on May 8, 2009

hii thanks for the above info, but its not satisfying my requirement

what i need to trace is not ust url with query strin but i also need to trace #href

i.e. if my url is http://jigishthakar.com/?p=2#cid

then till http://jigishthakar.com/?p=2 ur code works fine but now how to trace #cid ?

Posted By: mraiur on August 7, 2009

i need also to get whats after the "#" so if the "#" is encoded u can get it whit $GET, $POST, $_REQUEST etc. :)

Posted By: KabuqueJoe on March 19, 2011

i think, php can not get the values after # cause its not passed to the server.

You need to login to post a comment.