By 05/02/2014 1 Comments

How to get Remote IP Address in PHP

What is Remote IP address?

  • An IP address is an unique numeric value which is assign to each device such as computer,laptop,printer etc
  • A remote IP address is a unique numeric value or a number which can be used to connect to some one else’s computer from long way via internet connection

Get remote IP address through PHP.

function getRemoteIPAddress() { //function declaration

$ip = $_SERVER['REMOTE_ADDR']; // a super global server array which has a value, that value get the IP address of the user or client from current webpage

return $ip;

}

If your client is behind a proxy server then use this to get the real IP address.

function getRealIPAddr()
{

if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet

{

$ip=$_SERVER['HTTP_CLIENT_IP'];

}

elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy

{

$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];

}

else

{

$ip=$_SERVER['REMOTE_ADDR']; // a super global server array which has a value, that value get the IP address of the user or client from current webpage
} return $ip; 
}
?>






Posted in: PHP

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .