文章来源(hbsjsd.cn)湖北高端网站定制开发公司-速建时代
在网站开发过程中很多地方都都会用到IP获取用户所在城市这个小功能今天襄阳高端网站定制开发小编给大家分享一个简单小功能
获取IP传值
$ip = request()->ip();//获取IP $ip = $this->ip_address($ip);//传IP到ip_address中 我们是通过http://freeapi.ipip.net/端口来进行解析IP地址的
public function ip_address($ip = '')
{
$url = 'http://freeapi.ipip.net/' . $ip;
$result = file_get_contents($url);
$result = json_decode($result, true);
dump($result);
return $result;
}
最后效果
[声明]原创不易,请转发者备注下文章来源(hbsjsd.cn)【速建时代】。