Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php geolocation package


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 GeoIp2DatabaseReader;
// 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 . "
");
print($record->country->name . "
");
print($record->country->names['zh-CN'] . "
");
print($record->mostSpecificSubdivision->name . "
");
print($record->mostSpecificSubdivision->isoCode . "
");
print($record->city->name . "
");
print($record->postal->code . "
");
print($record->location->latitude . "
");
print($record->location->longitude . "
");
$>

Comment

PREVIOUS NEXT
Code Example
Php :: php print all woocommerce products 
Php :: Adding JavaScript to a Specific WordPress Post or Page Using Code in the Footer 
Php :: codeigniter update query return value 
Php :: php is int 
Php :: php set environment variable 
Php :: php file download from url 
Php :: symfony set timezone 
Php :: SPA and keep some of the Laravel pages you need to have a route like this 
Php :: How to disable Gutenberg / block editor for certain post types 
Php :: php artisan queue table 
Php :: cviebrock/eloquent-sluggable 
Php :: laravel validation in controller 
Php :: check installed php modules in linux 
Php :: find which php.ini is used 
Php :: get post by meta value 
Php :: carbon get day name 
Php :: md5 (PHP 4, PHP 5, PHP 7, PHP 8) md5 — Calculate the md5 hash of a string 
Php :: Syntax error or access violation: 1071 La clé est trop longue. Longueur maximale: 1000" 
Php :: php error log 
Php :: php close unclosed HTML Tags 
Php :: where in laravel 
Php :: How to order by using id with firstWhere in laravel 
Php :: laravel merge two query builder 
Php :: laravel validation double 
Php :: how laravel return the old value 
Php :: wordpress get category description 
Php :: laravel realation with has 
Php :: laravel collection average 
Php :: php get screen size 
Php :: laravel latest from relationship 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =