PHP code example of yasir-dev / ip-geolocation
1. Go to this page and download the library: Download yasir-dev/ip-geolocation 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/ */
yasir-dev / ip-geolocation example snippets
// use the package
use ipGeolocation\GeoIPLocation;
//get the ip address
$ipAddress = (new GeoIPLocation())->getIpAddress();
// get the location object
$location = (new GeoIPLocation())->getGeoLocation();
//check the status for success
$location->getStatus();
//get the (!$location->getStatus()) {
//get error message
$location->getMessage();
}