Ec (2); php tutorial to get the current url domain name instance code & nbsp; functiongetServerName () & nbsp ;{& nbsp; & nbsp; $ ServerNamestrtolower ($ _ SERVER [SERVER_NAME]? $ _ SERVER [SERVER_NAME]: $ _ SERVER [HTTP_HOST]); & nbsp; I script ec (2); script
Php tutorial to get the current url domain name instance code
Function getServerName ()
{
$ ServerName = strtolower ($ _ SERVER ['server _ name']? $ _ SERVER ['server _ name']: $ _ SERVER ['HTTP _ host']);
If (strpos ($ ServerName, 'HTTP ://'))
{
Return str_replace ('HTTP: // ', '', $ ServerName );
}
Return $ ServerName;
}
$ Url = getServerName ();
Echo $ url;
/*
Function Introduction
Strtolower converts characters to lowercase letters
Strpos ($ str, $ str1) determines the position where $ str1 exists in $ str
Str_replace ($ str, $ repalce, $ str1) replace the value of $ str1 string including the character $ str with $ replace
$ _ SERVER reference http://www.111cn.net/phper/21/php_SERVER.htm
More and better manual http://www.111cn.net/w3school/php/
*/
?>