PHP code example of myweishanli / yii2-ip2location

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

    

myweishanli / yii2-ip2location example snippets


use \wsl\ip2location\Ip2Location;

$ipLocation = new Ip2Location();
$locationModel = $ipLocation->getLocation('8.8.8.8');
print_r($locationModel->toArray());
// Array
// (
//     [ip] => 8.8.8.8
//     [begin_ip] => 8.8.8.8
//     [end_ip] => 8.8.8.8
//     [country] => 美国
//     [area] => 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器
// )

use \wsl\ip2location\QQWry;

$qqwry = new QQWry();
$qqwry->upgrade();