note 123492 added to book.geoip

From: Date: Sat, 05 Jan 2019 09:51:23 +0000
Subject: note 123492 added to book.geoip
Groups: php.notes 
Request: Send a blank email to php-notes+get-209997@lists.php.net to get a copy of this message
With GeoIP2, the easiest way is to: * Grab the latest GeoIP2 Lite Database(s): https://dev.maxmind.com/geoip/geoip2/geolite2/ * Grab the latest geoip2.phar: https://github.com/maxmind/GeoIP2-php/releases <?php require_once("geoip2.phar"); use GeoIp2\Database\Reader; // City DB $reader = new Reader('/path/to/GeoLite2-City.mmdb'); $record = $reader->city($_SERVER['REMOTE_ADDR']); // or for Country DB // $reader = new Reader('/path/to/GeoLite2-Country.mmdb'); // $record = $reader->country($_SERVER['REMOTE_ADDR']); print($record->country->isoCode . "\n"); print($record->country->name . "\n"); print($record->country->names['zh-CN'] . "\n"); print($record->mostSpecificSubdivision->name . "\n"); print($record->mostSpecificSubdivision->isoCode . "\n"); print($record->city->name . "\n"); print($record->postal->code . "\n"); print($record->location->latitude . "\n"); print($record->location->longitude . "\n"); $> ---- Server IP: 208.43.231.9 Probable Submitter: 2a01:4a0:38:1::3 (proxied: 220.237.117.161) ---- Manual Page -- http://php.net/manual/en/book.geoip.php Edit -- https://master.php.net/note/edit/123492 Del: integrated -- https://master.php.net/note/delete/123492/integrated Del: useless -- https://master.php.net/note/delete/123492/useless Del: bad code -- https://master.php.net/note/delete/123492/bad+code Del: spam -- https://master.php.net/note/delete/123492/spam Del: non-english -- https://master.php.net/note/delete/123492/non-english Del: in docs -- https://master.php.net/note/delete/123492/in+docs Del: other reasons-- https://master.php.net/note/delete/123492 Reject -- https://master.php.net/note/reject/123492 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209997) next »