timeshow / ip-location
ip-location for laravel
v0.2.5
2021-10-14 09:48 UTC
Requires
- php: >=7.0
README
#ip-location for Laravel
版本兼容性
Install
Composer 安装
$ composer require timeshow/ip-location
add the IpLocationServiceProvider
to your config/app.php
:
'providers' => [ // ... TimeShow\IpLocation\IpLocationServiceProvider::class, ]
'aliases' => [ // ... 'IpLocation' => TimeShow\IpLocation\Facades\IpLocation::class, ]
如何使用?
use TimeShow\IpLocation\IpLocation; $ipLocation = new IpLocation(); $ipLocation->getLocation('X.X.X.X'); $ipLocation->getArea('X.X.X.X'); $ipLocation->getCountry('X.X.X.X'); $ipLocation->getProvince('X.X.X.X'); $ipLocation->getCity('X.X.X.X'); $ipLocation->getCounty('X.X.X.X'); $ipLocation->getISP('X.X.X.X');
PS Q&A
1、返回结果出现中文乱码?
$ipLocation = new IpLocation(); $location = $ipLocation->getLocation('X.X.X.X'); mb_convert_encoding($location, "UTF-8", "gbk");