Problem Regarding server ip address

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
softsolvers
Forum Commoner
Posts: 75
Joined: Fri Feb 13, 2004 4:26 am
Location: India

Problem Regarding server ip address

Post 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
User avatar
Pointybeard
Forum Commoner
Posts: 71
Joined: Wed Sep 03, 2003 7:23 pm
Location: Brisbane, AUS
Contact:

Post by Pointybeard »

Umm, I believe that $_SERVER['SERVER_ADDR'] will give you the server IP address. that what you mean?
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Thats not a valid $_SERVER variant. Its $_SERVER["HTTP_HOST"]
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post 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.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post 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']
User avatar
Pointybeard
Forum Commoner
Posts: 71
Joined: Wed Sep 03, 2003 7:23 pm
Location: Brisbane, AUS
Contact:

Post by Pointybeard »

Yep, evilcoder, it works. have a look at your phpinfo some time. ;)
Post Reply