1. Go to this page and download the library: Download thbappy7706/geo-details 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/ */
thbappy7706 / geo-details example snippets
bash
e GeoDetails\GeoLocationService;
// Instantiate the GeoLocationService class
$geoService = new GeoLocationService();
// Specify the IP address you want to retrieve details for
$ip = '8.8.8.8';
// Fetch and display geolocation details
$latitude = $geoService->getLatitude($ip);
$longitude = $geoService->getLongitude($ip);
if ($latitude !== null && $longitude !== null) {
echo "Latitude: " . $latitude . ", Longitude: " . $longitude;
} else {
echo "Error: Unable to retrieve location details.";
}