Jump to content

Recommended Posts

$_SERVER['SERVERIP'] // the ip of the server

$_SERVER['SERVER_ADDR'] // the vhost ip, if your using more than one ip on the server

If 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]<?php

echo '<pre>' . print_r ( $_SERVER ) . '</pre>';
echo '<pre>' . print_r ( $_ENV ) . '</pre>';

?>[/code]


me!
Link to comment
https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110707
Share on other sites

[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?

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110708
Share on other sites

Thank you both for your quick replies.

When I loop through all the variables in $_SERVER with ...

[code]
<?php
while (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
Link to comment
https://forums.phpfreaks.com/topic/24341-server-ip-on-iis/#findComment-110721
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.