PHP code example of snipershady / ip2location

1. Go to this page and download the library: Download snipershady/ip2location library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

snipershady / ip2location example snippets


use IpToLocation\Service\IpInfoRetriever;


class fooClass(){
    public function getIpInfo(): \IpToLocation\Entity\IpInfo{
          $ipInfoRetriever = new \IpToLocation\Service\IpInfoRetriever();
          $ip = "8.8.8.8";
          return $ipInfoRetriever->findInfoByIp($ip);
    }
}

IpToLocation\Entity\IpInfo {
  -ip: "1.1.1.1"
  -countryCode: "AU"
  -countryName: "Australia"
  -regionName: "Queensland"
  -cityName: "Brisbane"
  -latitude: "-27.46754"
  -longitude: "153.02809"
  -zipCode: "4000"
  -timeZone: "+10:00"
  -asn: "13335"
  -as: "CloudFlare Inc."
  -isProxy: false
  -message: "Limit to 500 queries per day. Sign up for a Free plan at https://www.ip2location.io to get 30K queries per month."
}