class IPAddress extends Common
{
/**
* 根據ip地址,獲取用戶所在省市
*/
public function ipIndex()
{
$ip = "222.22.22.11";// 默認設置一個ip地址(可自行獲取)
include "../vendor/topthink/Iplocation.php";//引入文件
$Ips =new \IpLocation\IpLocation('UTFWry.dat'); // 實例化類 參數表示IP地址庫文件
$area = $Ips->getlocation($ip); // 獲取某個IP地址所在的位置
print_r($area);die;
}
}
下載類文件:https://github.com/joytom/ipLocation
打印數據:php
參考連接:https://blog.csdn.net/qq_42249896/article/details/85238541 git
淘寶相關接口(瀏覽器訪問):http://ip.taobao.com/service/getIpInfo.php?ip=222.22.22.11github