note 126808 added to book.geoip
| From: | ruben dot benjamin at hidden-email dot com | Date: | Thu, 27 Jan 2022 18:51:58 +0000 |
| Subject: | note 126808 added to book.geoip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217552@lists.php.net to get a copy of this message | ||
If you want to use the C Library
Example for Ubuntu and PHP 7.4
sudo apt install libmaxminddb0 libmaxminddb-dev mmdb-bin
pecl install maxminddb
vi /etc/php/7.4/mods-available/maxmind.ini
add
extension=maxminddb.so
phpenmod maxmind
In code
<?php
use MaxMind\Db\Reader;
$ipAddress = '24.24.24.24';
$databaseFile = '/usr/share/GeoIP/GeoLite2-Country.mmdb';
$reader = new Reader($databaseFile);
// get returns just the record for the IP address
print_r($reader->get($ipAddress));
// getWithPrefixLen returns an array containing the record and the
// associated prefix length for that record.
print_r($reader->getWithPrefixLen($ipAddress));
$reader->close();
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 66.175.245.5)
----
Manual Page -- https://php.net/manual/en/book.geoip.php
Edit -- https://main.php.net/note/edit/126808
Del: integrated -- https://main.php.net/note/delete/126808/integrated
Del: useless -- https://main.php.net/note/delete/126808/useless
Del: bad code -- https://main.php.net/note/delete/126808/bad+code
Del: spam -- https://main.php.net/note/delete/126808/spam
Del: non-english -- https://main.php.net/note/delete/126808/non-english
Del: in docs -- https://main.php.net/note/delete/126808/in+docs
Del: other reasons-- https://main.php.net/note/delete/126808
Reject -- https://main.php.net/note/reject/126808
Search -- https://main.php.net/manage/user-notes.php