php getsiteurl() function_PHP tutorial

WBOY
Release: 2016-07-21 15:44:45
Original
1001 people have browsed it

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

www.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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!