|
{
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其实是个数组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']通过三目运算后把结果给$url
//$_SERVER也是数组,你可以打印一下,就知道干吗用的了.这里只涉及到三个数组元素
//$_SERVER['REQUEST_URI']; //REQUEST_URI:/mysite/->站点目录?
//$_SERVER['php_SELF']; //php_SELF:/mysite/index.php->当前正在执行脚本的文件名
//$_SERVER['SCRIPT_NAME']; //SCRIPT_NAME:/mysite/index.php->包含当前脚本的路径
php技术:php getsiteurl()函数,转载需保留来源!
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。