php getsiteurl()函数

前端之家收集整理的这篇文章主要介绍了php getsiteurl()函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="44918" class="copybut" id="copybut44918" onclick="doCopy('code44918')"> 代码如下:

<div class="codebody" id="code44918">function getsiteurl()
{
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,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->包含当前脚本的路径

原文链接:https://www.f2er.com/php/29054.html

猜你在找的PHP相关文章