Getting IP address in php
<p>I am this code to get the IP address on my locolhost and I get</p>

<pre><code>::1
</code></pre>

<p>result</p>

<p>code is:</p>

<pre><code>function ip()
{
  if (!empty($_SERVER['HTTP_CLIENT_IP']))
  {
       $ip = $_SERVER['HTTP_CLIENT_IP'];
  } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  }
  else
  {
    $ip = $_SERVER['REMOTE_ADDR'];
  }
  return $ip;            
}

echo ip();
</code></pre>

<p>where is error?</p>

<p>Actually, I want to get country &amp; city name after I get IP... Any other solution?</p>

<p>Thanks</p>
