Home > Backend Development > PHP Tutorial > hummell gets the rockets php getsiteurl函数

hummell gets the rockets php getsiteurl函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:40:38
Original
1318 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 the global variable $_SCONFIG ($_SCONFIG is actually an array var, defined in common.php)
if(empty($_SCONFIG['siteallurl'])) //Judge the $_SCONFIG['siteallurl'] variable Is it 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, just You 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->The path containing the current script
The above introduces the hummell gets the rockets php getsiteurl function, including the content of hummell gets the rockets. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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