title: How to find country using IP address in PHP?
body: <p>I have IP ranges of the country. And I am checking the the user IP address within this ranges if true then he is able to see the site otherwise he wont.
  I have use following code,</p>
  
  <pre><code>$ip = $_SERVER['REMOTE_ADDR'];
     if(ip2long($ip) &gt;= $ipstart &amp;&amp; ip2long($ip) &lt;= $ipend){
          return true;
      } 
  </code></pre>
  
  <p>My question is that if somebody comes from different country suppose ABC with his laptop/notebook to another country suppose XYZ then <strong>will above code works?</strong> on the same laptop.</p>
  
  <p><strong>How will it be possible for the above scenario for ipv4 and ipv6?</strong></p>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>Which IP address <code>$_SERVER['REMOTE_ADDR']</code> fetch, will it be the machine IP or the connection IP, so that we can know that he now in this country?</p>
  
  <p>Thanks</p>