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

列印資料:

參考鏈接:https://blog.csdn.net/qq_42249896/article/details/85238541
淘寶相關介面(瀏覽器訪問):http://ip.taobao.com/service/getIpInfo.php?ip=222.22.22.11

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/122682.html
標籤:PHP
