$ip= $REMOTE_ADDR;
GetHostByName($REMOTE_ADDR);
OR
if( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ){ print $_SERVER['HTTP_X_FORWARDED_FOR']; }OR
getenv('REMOTE_ADDR');
Sample output : 192.168.1.56
The above code will only print the IP address, if the x-forwarded-for header is updated by the gateway of client. Otherwise it is not possible to detect the thing. If 100 users are browsing your page, it can happen that 10 of them you can get the actual IP address, and others are only showing the gateway IP address.
No comments:
Post a Comment