PHP code example of zqhong / ip-location-zh

1. Go to this page and download the library: Download zqhong/ip-location-zh 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/ */

    

zqhong / ip-location-zh example snippets


use Zhuzhichao\IpLocationZh\Ip;

$ipInfo = Ip::findV2("47.96.140.2");

printf("%s%s%s(%s)",
    $ipInfo->getCountry(),
    $ipInfo->getProvince(),
    $ipInfo->getCity(),
    $ipInfo->getIsp()
);

// 返回结果:中国 浙江 杭州(阿里云)
// 具体代码请参考:examples.php
bash
./vendor/bin/phpunit ./tests/*.php