PDA

View Full Version : URL As Variable


Serex
06-01-2005, 07:26 AM
Hey just wondering if there was a way to pull the entire URL into a variable. So maybe you could explode it and break it down abit.

Just curious.
thanks

Bill Posters
06-01-2005, 08:48 AM
e.g.
$full_url = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

SeeIT Solutions
06-01-2005, 08:52 AM
$full_url = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];

Bill Posters
06-01-2005, 09:04 AM
$full_url = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];

Good idea to consider any query string, but, imho, you should check for the presence of a query string before echoing a ? character that is redundant and potentially confusing to users.

e.g.

$full_url = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

if ($_SERVER['QUERY_STRING']) {
$full_url .= "?".$_SERVER['QUERY_STRING'];
}

Serex
06-01-2005, 02:00 PM
Thanks for that Bill. Muchly apreciated