Click to See Complete Forum and Search --> : Grab whole URL of current page?


strBean
02-22-2007, 08:32 AM
Hi

I've used $_SERVER["PHP_SELF"] to grab the address of the current page. Now I need to grab the address and the GET string also. Is there a built-in function hthat just returns the whole URL? I looked at the manual and got lost.

Also, I'm curious if $_GET works as a numeric array. I mean, is it possible to loop through all the values in $_GET?

Taschen
02-22-2007, 09:12 AM
$_SERVER['QUERY_STRING'] - gives you the query string. Here are some more:
$_SERVER['HTTP_HOST']
$_SERVER['DOCUMENT_ROOT']
$_SERVER['HTTP_REFERER']
$_SERVER['REQUEST_URI']

Try this with your query string:
$test = $_GET; //Note there is no array key
foreach($test as $key => $val){
echo 'key: '.$key.' | value: '.$val.'<br />';
}
print_r($_GET); would work too of course.

strBean
02-22-2007, 09:48 AM
Thanks a bunch!

I knew some of this once. Too many hats...

Shears
02-22-2007, 11:49 AM
So many and they all seem to do the same thing - there must be some difference between them :-S