Page 1 of 1

Problem Regarding server ip address

Posted: Sat Mar 13, 2004 1:29 am
by softsolvers
Hello friends
I am working on an applicaion in which in the config file i had made a hard code of the local server. Now is there is any way that i can get the ip address of the server and can access the images accordingly,i had made the application of register_global=on
So plz. suggest me by considering that it is on.
Looking for repply.
Thanks

Posted: Sat Mar 13, 2004 6:20 am
by Pointybeard
Umm, I believe that $_SERVER['SERVER_ADDR'] will give you the server IP address. that what you mean?

Posted: Sat Mar 13, 2004 7:51 am
by evilcoder
Thats not a valid $_SERVER variant. Its $_SERVER["HTTP_HOST"]

Posted: Sat Mar 13, 2004 8:52 am
by Straterra
IMHO, the only truly accurate way to find out one's IP adress is for another to tell him his IP adress. When I write Legacy VB (4, 5, 6) programs, I simply get the HTML code from http://www.whatismyip.com and parse out the IP. You could from there compare the predefined to the parsed IP. They should match, but if they don't, I would use the parsed IP.

Posted: Sat Mar 13, 2004 10:10 am
by Illusionist
evilcoder wrote:Thats not a valid $_SERVER variant. Its $_SERVER["HTTP_HOST"]
uhh... yes $_SERVER['SERVER_ADDR'] is too valid. I use it in quite a few of my projects.

http://px.sklar.com/code.html?id=1000

Posted: Sat Mar 13, 2004 1:04 pm
by penguinboy
I believe it is undocumented.

Try:

Code: Select all

print '<pre>';
print_r($_SERVER);
Among others; you'll see:

Code: Select all

$_SERVER['SERVER_ADDR']

Posted: Sat Mar 13, 2004 6:38 pm
by Pointybeard
Yep, evilcoder, it works. have a look at your phpinfo some time. ;)