PHPackages                             jfcherng/php-ip-location - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jfcherng/php-ip-location

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jfcherng/php-ip-location
========================

利用 IP 查詢地理位置。

3.0.6(3y ago)3321↓100%MITPHPPHP &gt;=7.1.3CI failing

Since Apr 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jfcherng/php-ip-location)[ Packagist](https://packagist.org/packages/jfcherng/php-ip-location)[ Fund](https://www.paypal.me/jfcherng/5usd)[ RSS](/packages/jfcherng-php-ip-location/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (6)Versions (17)Used By (0)

php-ip-location
===============

[](#php-ip-location)

[![GitHub Workflow Status (branch)](https://camo.githubusercontent.com/47bd36f6b386973c2695eacbbbbdd7eecd7c4dcd9875e0e0b223789565a009fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a66636865726e672f7068702d69702d6c6f636174696f6e2f7068702e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/jfcherng/php-ip-location/actions)[![Packagist](https://camo.githubusercontent.com/5459243306818a558b9114475c3ef4282f4cb19e937438daa44f1b79c7a3eaf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a66636865726e672f7068702d69702d6c6f636174696f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jfcherng/php-ip-location)[![Packagist Version](https://camo.githubusercontent.com/af824d386be0dec3978a36833714d0036ded80f73cb6349f6fdcabb3bc77ec7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a66636865726e672f7068702d69702d6c6f636174696f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jfcherng/php-ip-location)[![Project license](https://camo.githubusercontent.com/1b81a158a94af8ef4c27da9eb60e90ad30bfca7a0ba51969637bc48f6472710a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a66636865726e672f7068702d69702d6c6f636174696f6e3f7374796c653d666c61742d737175617265)](https://github.com/jfcherng/php-ip-location/blob/master/LICENSE)[![GitHub stars](https://camo.githubusercontent.com/82af3c5b57764713508e1bf7cb6b4b5dd057dd716af710e6d08e02c661f2c729/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a66636865726e672f7068702d69702d6c6f636174696f6e3f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/jfcherng/php-ip-location/stargazers)[![Donate to this project using Paypal](https://camo.githubusercontent.com/b3f28a26023aadc92afb98cdbcec5f66ed5b471222cf2af28454b871d93372f4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d626c75652e7376673f7374796c653d666c61742d737175617265266c6f676f3d70617970616c)](https://www.paypal.me/jfcherng/5usd)

利用 `IPIP` 和 `cz88 （純真）` 兩個資料庫來查詢 IP 的地理位置。

安裝流程
----

[](#安裝流程)

1. 使用 Composer 安裝： `composer require jfcherng/php-ip-location`
2. 這樣就可以了，但如果你想要自己更新 IP 資料庫，請參考以下步驟：

    1. 取得 IPIP.net 的 IP 離線資料庫 (`ipipfree.ipdb`)

        - 從  下載免費版離線資料庫 （需要登入以及手機驗證，可以免費註冊帳號）
    2. 純真 IP 資料庫 (`qqwry.dat`) 的 IPDB 格式版本

        - 從  下載[標準版](https://cdn.jsdelivr.net/npm/qqwry.ipdb/qqwry.ipdb)
    3. 於使用時自行設定兩個資料庫的路徑

使用方式
----

[](#使用方式)

見 `demo.php`

```
