dev-master
9999999-dev利用 IP 查詢地理位置。
The Requires
- php ^7.1.3
The Development Requires
by Jack Cherng
1.0.0
1.0.0.0利用 IP 查詢地理位置。
The Requires
- php ^7.1.3
The Development Requires
by Jack Cherng
利用 IP 查詢地理位置。
利用 IPIP
和 cz88 (純真)
兩個資料庫來查詢 IP 的地理位置。, (*2)
使用 Composer 安裝: composer require jfcherng/php-ip-location
, (*3)
這樣就可以了,但如果你想要自己更新 IP 資料庫,請參考以下步驟:, (*4)
ipipfree.ipdb
)qqwry.dat
) 的 IPDB 格式版本見 demo.php
, (*5)
<?php use Jfcherng\IpLocation\IpLocation; include __DIR__ . '/vendor/autoload.php'; $ipFinder = IpLocation::getInstance(); // 如果不想要使用內建的 IP 資料庫,請進行以下設定 $ipFinder->setup([ // ipip 資料庫的路徑 'ipipDb' => __DIR__ . '/src/db/ipipfree.ipdb', // cz88 資料庫的路徑 'cz88Db' => __DIR__ . '/src/db/qqwry.ipdb', ]); $ip = '202.113.245.255'; $results = $ipFinder->find($ip); \var_dump($results); /* array(5) { ["country_name"]=> string(6) "中国" ["region_name"]=> string(6) "天津" ["city_name"]=> string(6) "天津" ["owner_domain"]=> string(0) "" ["isp_domain"]=> string(9) "教育网" } */
利用 IP 查詢地理位置。
利用 IP 查詢地理位置。