PHP 的 ip 地址获取类【Ip2Region】
Composer 地址:
composer require zoujingli/ip2region
// ip 定位
public function getCity()
{
$ip = input('param.ip');
$ip2region = new \Ip2Region();
$info = $ip2region->btreeSearch($ip);
$city = explode('|', $info['region']);
if(0 != $info['city_id']){
return json(['code' => 1, 'data' => $city['2'] . $city['3'] . $city['4'], 'msg' => 'ok']);
}else{
return json(['code' => 1, 'data' => $city['0'], 'msg' => 'ok']);
}
}
本文来自博客园,作者:只要AD钙奶,转载请注明原文链接:https://www.cnblogs.com/carver/articles/16633271.html

浙公网安备 33010602011771号