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
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Server IP Address

Post by amir »

Hello all here's one for you.

I need to get the server_addr global variable. Sounds easy, but here's the kicker, I'm on IIS and as I understand it, this variable is not available. How do I get the IP Address of the server?
User avatar
Obadiah
Forum Regular
Posts: 580
Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:

Post by Obadiah »

i never had to do this...but have you looked here

http://us2.php.net/reserved.variables/
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post by akimm »

like the previous poster alluded to,

Code: Select all

<?php

$SERVER['REMOTE_ADDR'];

##or

getenv("SERVER_NAME");

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

REMOTE_ADDR is the requesting agent's IP address. ;)

SERVER_ADDR is the server's, typically.
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

Yes, but as I've noted, that variable is not available in IIS.
Post Reply