1. Go to this page and download the library: Download munna/iplocation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
munna / iplocation example snippets
// Use this as namespace
use Munna\IpLocation\IpLocation;
// Set Your Ip Address
$ip = "YOUR_IP_ADDRESS";
//this is optional. Find this api key by visiting https://ipinfo.io/account/home?service=google&loginState=create
$api_key = "API_TOKEN";
//If you have this api_key
$location = new IpLocation($ip, $api_key);
// If you do not have this api_key pass only ip
$location = new IpLocation($ip);
// Finally init the class
$location->init();
// Get Ip Address
$ip = $location->ip;
//full info as an array
$info = $location->info();
// get region name
$region = $location->region;
// get country
$country = $location->country;
// get city name If you set api_key when create instance
$cityName = $location->city;
// get ioc name
$loc = $location->loc;
// get postal
$postal = $location->postal;
// get flag url
$flag = $location->flag;
// get timeZone
$timeZone = $location->timeZone;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.