bfisher Posted October 18, 2006 Share Posted October 18, 2006 Hello all.I need to obtain the server's IP address, but since I'm on IIS, I can't use the $SERVER_ADDR global variable. Can anyone suggest another course of action? By the way I'm new to PHP, so I apologize in advance if I use incorrect terminology. Quote Link to comment https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/ Share on other sites More sharing options...
printf Posted October 18, 2006 Share Posted October 18, 2006 $_SERVER['SERVERIP'] // the ip of the server$_SERVER['SERVER_ADDR'] // the vhost ip, if your using more than one ip on the serverIf there not found in the SERVER array, then they will be found in the $_ENV array, it depends on the PHP version you are using (CGI/ISAPI)...Just do this, to see where it is![code]<?phpecho '<pre>' . print_r ( $_SERVER ) . '</pre>';echo '<pre>' . print_r ( $_ENV ) . '</pre>';?>[/code]me! Quote Link to comment https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110707 Share on other sites More sharing options...
HuggieBear Posted October 18, 2006 Share Posted October 18, 2006 [quote author=bfisher link=topic=111907.msg453803#msg453803 date=1161182085]but since I'm on IIS, I can't use the $SERVER_ADDR global variable.[/quote]I'm assuming you mean [code=php:0]$_SERVER['SERVER_ADDR'][/code]Why can't you use that?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110708 Share on other sites More sharing options...
bfisher Posted October 18, 2006 Author Share Posted October 18, 2006 Thank you both for your quick replies.When I loop through all the variables in $_SERVER with ...[code]<?phpwhile (list($var,$value) = each($_SERVER)){echo "$var => $value <br>";}?>[/code]... I get the following, but no SERVER_ADDR.ALL_HTTP => HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_LANGUAGE:en-us HTTP_CONNECTION:Keep-Alive HTTP_HOST:localhost HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) HTTP_UA_CPU:x86 HTTP_ACCEPT_ENCODING:gzip, deflate HTTPS => off SCRIPT_NAME => /globals.php HTTP_COOKIE => AUTH_PASSWORD => AUTH_TYPE => AUTH_USER => CONTENT_LENGTH => 0 CONTENT_TYPE => PATH_TRANSLATED => c:\inetpub\wwwroot QUERY_STRING => REMOTE_ADDR => 127.0.0.1 REMOTE_HOST => 127.0.0.1 REMOTE_USER => REQUEST_METHOD => GET SERVER_NAME => localhost SERVER_PORT => 80 SERVER_PROTOCOL => HTTP/1.1 SERVER_SOFTWARE => Microsoft-IIS/5.1 APPL_MD_PATH => /LM/W3SVC/1/ROOT APPL_PHYSICAL_PATH => c:\inetpub\wwwroot\ INSTANCE_ID => 1 INSTANCE_META_PATH => /LM/W3SVC/1 LOGON_USER => REQUEST_URI => /globals.php URL => /globals.php SCRIPT_FILENAME => C:\Inetpub\wwwroot/globals.php ORIG_PATH_INFO => /globals.php PATH_INFO => ORIG_PATH_TRANSLATED => c:\inetpub\wwwroot\globals.php DOCUMENT_ROOT => c:\inetpub\wwwroot PHP_SELF => /globals.php HTTP_ACCEPT => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_LANGUAGE => en-us HTTP_CONNECTION => Keep-Alive HTTP_HOST => localhost HTTP_USER_AGENT => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) HTTP_UA_CPU => x86 HTTP_ACCEPT_ENCODING => gzip, deflate REQUEST_TIME => 1161183243 I used the same loop code to loop through $_ENV, but I don't get anything at all.-Bfisher Quote Link to comment https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110721 Share on other sites More sharing options...
printf Posted October 18, 2006 Share Posted October 18, 2006 what type of PHP are you running (CGI, ISAPI) and the version.me Quote Link to comment https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110736 Share on other sites More sharing options...
bfisher Posted October 18, 2006 Author Share Posted October 18, 2006 ISAPI on IIS 6 on Windows XP Pro SP2 Quote Link to comment https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110790 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.