取得当前得页面url
取得当前得页面URL
sports98 2004-03-01 15
用 $_SERVER[SERVER_NAME].$_SERVER[PHP_SELF] 参数和端口取不到
//写了一个函数,获得当前页面的绝对的Url(可能的https,端口,以及参数)
function AbsoluteUrl() {
GLOBAL $HTTP_SERVER_VARS;
$HTTPS =$HTTP_SERVER_VARS["HTTPS"];
$HTTP_HOST =$HTTP_SERVER_VARS["HTTP_HOST"];
$SCRIPT_URL =$HTTP_SERVER_VARS["SCRIPT_URL"];
$PATH_INFO =$HTTP_SERVER_VARS["PATH_INFO"];
$REQUEST_URI=$HTTP_SERVER_VARS["REQUEST_URI"];
$SCRIPT_NAME=$HTTP_SERVER_VARS["SCRIPT_NAME"];
$QUERY_STRING=$HTTP_SERVER_VARS["QUERY_STRING"];
if (get_magic_quotes_gpc()==1) $QUERY_STRING=stripslashes($QUERY_STRING);
if ($QUERY_STRING!="") $QUERY_STRING="?".$QUERY_STRING;
$uri_http=(((strtolower($HTTPS)=="off")or($HTTPS==0)) ? 'http' : 'https') . '://' . $HTTP_HOST ;
if (isset($SCRIPT_URL))
$url=$SCRIPT_URL;
else if (isset($PATH_INFO))
$url = $PATH_INFO;
else if (isset($REQUEST_URI))
$url = $REQUEST_URI;
else if (isset($SCRIPT_NAME))
$url = $SCRIPT_NAME;
$url=$uri_http.$url.$QUERY_STRING;
return $url;
}