用 $_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;
}