|
{
global $_SCONFIG;
if(empty($_SCONFIG['siteallurl']))
{
$uri = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['php_SELF']?$_SERVER['php_SELF']:$_SERVER['SCRIPT_NAME']);
return shtmlspecialchars('http://'.$_SERVER['HTTP_HOST'].substr($uri, 0, strrpos($uri, '/')+1));
}
else
{
return $_SCONFIG['siteallurl'];
}
}
global $_SCONFIG; //定義全局變量$_SCONFIG($_SCONFIG其實(shí)是個數(shù)組var,在common.php中有定義)
if(empty($_SCONFIG['siteallurl'])) //判斷$_SCONFIG['siteallurl']變量是否為空
$uri = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['php_SELF']?$_SERVER['php_SELF']:$_SERVER['SCRIPT_NAME']);
//將$_SERVER['REQUEST_URI'];$_SERVER['php_SELF'];$_SERVER['SCRIPT_NAME']通過三目運(yùn)算后把結(jié)果給$url
//$_SERVER也是數(shù)組,你可以打印一下,就知道干嗎用的了.這里只涉及到三個數(shù)組元素
//$_SERVER['REQUEST_URI']; //REQUEST_URI:/mysite/->站點(diǎn)目錄?
//$_SERVER['php_SELF']; //php_SELF:/mysite/index.php->當(dāng)前正在執(zhí)行腳本的文件名
//$_SERVER['SCRIPT_NAME']; //SCRIPT_NAME:/mysite/index.php->包含當(dāng)前腳本的路徑
php技術(shù):php getsiteurl()函數(shù),轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。