PHP code example of g4 / geoip
1. Go to this page and download the library: Download g4/geoip 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/ */
g4 / geoip example snippets
php
$geoIp = new \G4\GeoIP\GeoIP('127.0.0.1');
// "area_code" -- The PSTN area code (ex: 212)
echo $geoIp->getAreaCode();
// "dma_code" -- Designated Market Area code (USA and Canada only)
echo $geoIp->getDmaCode();
// "city" -- The city
echo $geoIp->getCity();
// "continent_code" -- Two letter continent code
echo $geoIp->getContinentCode();
// "country_code" -- Two letter country code
echo $geoIp->getCountryCode();
// "country_code3" -- Three letter country code
echo $geoIp->getCountryCode3();
// "country_name" -- The country name
echo $geoIp->getCountryName();
// IP address
echo $geoIp->getIp();
// "latitude" -- The Latitude as signed double
echo $geoIp->getLatitude();
// "longitude" -- The Longitude as signed double
echo $geoIp->getLongitude();
// "postal_code" -- The Postal Code, FSA or Zip Code
echo $geoIp->getPostalCode();
// "region" -- The region code (ex: CA for California)
echo $geoIp->getRegion();