PHP code example of niaoyoo / iplocation

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

    

niaoyoo / iplocation example snippets


use IpLocation;

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