PHP code example of graymatterlabs / geoip
1. Go to this page and download the library: Download graymatterlabs/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/ */
graymatterlabs / geoip example snippets
use GrayMatterLabs\GeoIp\GeoIp;
// $locator = new GrayMatterLabs\GeoIp\Locators\Cached($locator, $cache);
$geoip = new GeoIp($locator);
$location = $geoip->locate($ip);
$location->getCountryCode(); // 'US'
if ($location->isDefault()) {
//
}