Click to See Complete Forum and Search --> : Detect Server?


Zlord
06-10-2005, 04:07 PM
I was simply wondering if there was a way to detect which server you are using,


I.E. www.webdeveloper.com OR www.developer.com

and save that as a variable, for instance
$var1 = www.webdeveloper.com
$var2 = www.developer.com

If this is possible, could someone post me the code for it?

Thanks in advance :)

NogDog
06-10-2005, 07:37 PM
$_SERVER['SERVER_NAME']

Zlord
06-12-2005, 10:44 PM
so, if the server was not in backup mode, we would have
$var1 = www.webdeveloper.com
$var2 = www.developer.com

if(isset($_SERVER['$var1']))
code here
else if(isset($_SERVER['$var2']))
other code here


Would this be along those lines?

NogDog
06-12-2005, 11:05 PM
No, "SERVER_NAME" is a literal string used as as index into the $_SERVER array of pre-defined variables.

switch($_SERVER['SERVER_NAME'])
{
case "www.webdeveloper.com":
# code here;
break;
case "www.developer.com":
# code here;
break;
default:
# hmmm...using an unexpected server???
}