On Tuesday, June 25, 2002, at 02:56  PM, Harriet Xing wrote:

> Would anyone know how to get the http request url string in php?
> i.e., if the request is "http://www.myserver.com/test.php?param1=123";, 
> how can I obtain this string in test.php?

$request = "http://"; . $_SERVER['HTTP_HOST'] . "/" . 
$_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];


However, I don't like using $_SERVER['QUERY_STRING'] because if there 
are empty GET variables, it grabs them.  So, if you prefer, you can do 
this:

$getVarsArr = array();
foreach ($_GET as $getVarName => $getVarVal) {
        $getVars[] = $getVarName . "=" . $getVarVal;
}
$getVarsStr = implode("&", $getVars);
$request = "http://"; . $_SERVER['HTTP_HOST'] . "/" . 
$_SERVER['PHP_SELF'] . "?" . $getVarsStr;



Erik




----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to