Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
require_once '/usr/share/php/GeoIP2-php/vendor/autoload.php';
use GeoIp2\Database\Reader;
function get_country_isocode() {
global $country_isocode;
if (empty($country_isocode)) {
$reader = new Reader('/usr/share/GeoIP/GeoLite2-Country.mmdb');
$record = $reader->country($_SERVER["REMOTE_ADDR"]);
$country_isocode = $record->country->isoCode;
return $country_isocode;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.