• Register

How to get client IP address using PHP at server side?

0 like 0 dislike
How to get User IP address using PHP script? I want to display visitor IP address using PHP Code.
asked Mar 21, 2016 by anonymous

1 Answer

0 like 0 dislike
Best answer

You can use $_SERVER['REMOTE_ADDR'] like this:


There is also another example that can detect IP address behind proxy:

function GetIP(){
$ipaddress =  array();
  if (isset(
$ipaddress[] = $_SERVER['HTTP_CLIENT_IP'];
$ipaddress[] = $_SERVER['HTTP_X_FORWARDED_FOR'];
$ipaddress[] = $_SERVER['HTTP_X_FORWARDED'];
$ipaddress[] = $_SERVER['HTTP_FORWARDED_FOR'];
$ipaddress[] = $_SERVER['HTTP_FORWARDED'];
$ipaddress[] = $_SERVER['REMOTE_ADDR'];
$ips implode(", "array_unique($ipaddress));


answered Mar 21, 2016 by anonymous
selected Mar 21, 2016 by learnipaddress
Please check our IP Tools - This Project sponsored by STANDING Tech Company