Geoip php
$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $details->city; // -> "Mountain View"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");
$>
Also in PHP:
- db seed laravle
- check type of result php
- check if a word exist in a string php
- clear command in laravel
- create new project laravel
- echo in console php
- create new laravel project composer
- REMOVE php error and warning
- add 2 days in php
- error log all php
- 'f' means in date [h[
- database seeding in laravel
- check all file in server php
- Laravel Eloquent, group by month/year
- advance custon feilds
- current date and time php
- * in array key php
- create laravel seeder
- You want to develop a Laravel application on your Windows machine. For this, you installed the Laravel framework on your system. In which of the following scenarios, Laravel will not run on your system?
- copnsole log in php
- displaying error php
- access PHP error log
- convert lower to upper case php
- eloquent limit vs take