By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

how to get ip address of client in php script???

P: n/a
how can i get ip address of client in my php script???
thxs

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You can get the IP by using the following bit of code:

### get IP address ###
$ip = (getenv(HTTP_X_FORWARDED_FOR))
? getenv(HTTP_X_FORWARDED_FOR)
: getenv(REMOTE_ADDR);
Best regards,

Michel
"vishal" <vi************@yahoo.co.in> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
how can i get ip address of client in my php script???
thxs

Jul 17 '05 #2

P: n/a
is it same as getting ip address using

$ip = $_SERVER["REMOTE_ADDR"];

is there any difference ??

Jul 17 '05 #3

P: n/a
Personally i prefer:
$isp = isset($REMOTE_HOST) ? $REMOTE_HOST :
@gethostbyaddr($REMOTE_ADDR);

Since ip addresses change more often, this should give you more
consistent information for eg a counter...

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.