PHP code example of sunxiaozheng / laravel-ip2address

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

    

sunxiaozheng / laravel-ip2address example snippets




use Sunxiaozheng\Ip\Addr;

$ip = '1.86.10.173';
$param = ''; 
/*
 * 传入prov返回该IP所在的省份
 * 传入cy返回该IP所在的城市
 * 传入net返回该IP所在的运营商(移动、联通、电信)
 * 不传默认返回该IP所在的省份+城市
 */
var_dump(Addr::get($ip, $param));

'aliases' => array(
    'Addr'  => 'Sunxiaozheng\Ip\Addr',
),