PHP code example of qingbing / pf-tools-ip

1. Go to this page and download the library: Download qingbing/pf-tools-ip 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/ */

    

qingbing / pf-tools-ip example snippets



// 获取国家、省份、城市信息(用索引返回)
var_dump(\Tools\Ip::getInstance()->getCity()->find('118.28.1.1', 'CN'));
// 获取国家、省份、城市信息(用键值返回)
var_dump(\Tools\Ip::getInstance()->getCity()->findMap('118.28.1.1', 'CN'));
// 获取ip详细信息,免费版基本无用
var_dump(\Tools\Ip::getInstance()->getCity()->findInfo('118.28.1.1', 'CN'));


Array
(
    [0] => 中国
    [1] => 天津
    [2] => 天津
)
Array
(
    [country_name] => 中国
    [region_name] => 天津
    [city_name] => 天津
)
IpSupports\CityInfo Object
(
    [country_name] => 中国
    [region_name] => 天津
    [city_name] => 天津
    [owner_domain] => 
    [isp_domain] => 
    [latitude] => 
    [longitude] => 
    [timezone] => 
    [utc_offset] => 
    [china_admin_code] => 
    [idd_code] => 
    [country_code] => 
    [continent_code] => 
    [idc] => 
    [base_station] => 
    [country_code3] => 
    [european_union] => 
    [currency_code] => 
    [currency_name] => 
    [anycast] => 
)