Home > Backend Development > PHP Tutorial > php getsiteurl() function_PHP tutorial

php getsiteurl() function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:44:45
Original
1106 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:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template