侧边栏壁纸

PHP 的 ip 地址获取类【Ip2Region】

2024年03月25日 339阅读 0评论 0点赞


PHP:

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']);
        }
    }
0
打赏

—— 评论区 ——

昵称
邮箱
网址
取消
舔狗日记