PHP code example of testingmic / geoip2country
1. Go to this page and download the library: Download testingmic/geoip2country 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/ */
testingmic / geoip2country example snippets
composer
try
{
$IpAddressGeo = new testingmic\IpAddressGeoLocation();
} catch (\Throwable $th) {
trigger_error($th->getMessage(), E_USER_ERROR);
}
$ipAddress_1='37.140.250.97';
echo '<pre>';
print_r($IpAddressGeo->resolve($ipAddress_1));
Array
(
[start] => 629996032
[end] => 629996288
[country_code] => UA
[country_name] => United States
[continent_code] => NA
[city] => Alexandria
[latitude] => 38.8031
[longitude] => -77.0388
)
echo '<pre>';
print_r($IpAddressGeo->resolve()); /** resolve() method called without any argument */