Copy code The code is as follows:
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, 0, strrpos($uri, '/')+ 1));
}
else
{
return $_SCONFIG['siteallurl'];
}
}
global $_SCONFIG; / /Define global variable $_SCONFIG ($_SCONFIG is actually an array var, defined in common.php)
if(empty($_SCONFIG['siteallurl'])) //Judge $_SCONFIG['siteallurl' ] Is the variable empty
$uri = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:$_SERVER[ 'SCRIPT_NAME']);
//Put $_SERVER['REQUEST_URI'];$_SERVER['PHP_SELF'];$_SERVER['SCRIPT_NAME'] through ternary operation and give the result to $url
//$_SERVER is also an array, you can print it and you will know what it is used for. Only three array elements are involved here
//$_SERVER['REQUEST_URI']; //REQUEST_URI :/mysite/->Site directory?
//$_SERVER['PHP_SELF']; //PHP_SELF:/mysite/index.php->The file name of the currently executing script
//$_SERVER['SCRIPT_NAME']; //SCRIPT_NAME:/mysite/index.php->Path containing the current script
http://www.bkjia.com/PHPjc/320518.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320518.htmlTechArticleCopy the code The code is as follows: function getsiteurl() { global $_SCONFIG; if(empty($_SCONFIG['siteallurl' ])) { $uri = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['PHP_SELF...