PHP code example of ivoglent / ip2c

1. Go to this page and download the library: Download ivoglent/ip2c 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/ */

    

ivoglent / ip2c example snippets



use ivoglent\ip2c\IpLocator;

$ip = '186.95.255.255;
$ipLocator = new IpLocator($ip);
if ($ipLocator->analysis()) {
    echo sprintf('%s : %s, %s, %s', $ip, $ipLocator->getArea(), $ipLocator->getCountryCode(), $ipLocator->getCoutryName()) . PHP_EOL;
} else {
    echo 'Can not detect this IP address' . PHP_EOL;
}