In this Get Visitor Information by IP Address in PHP post, you will learn how to get a visitor’s full details, like timezone, country, IP address, Country Code, state, region, Continent Code, latitude, Continent Name, longitude, Currency Code and so on, using the visitor’s IP address using Core PHP programming language.
$ip_address = $_SERVER['REMOTE_ADDR'];
$ip_address_info = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip_address));
Complete PHP Code: Get Visitor Information by IP Address in PHP
Contents
<?php $ip = $_SERVER['REMOTE_ADDR']; $ip_address_info = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip)); if($ip_address_info && $ip_address_info->geoplugin_countryName != null){ echo 'Country Name = '.$ip_address_info->geoplugin_countryName.'<br/>'; echo 'Country Code = '.$ip_address_info->geoplugin_countryCode.'<br/>'; echo 'City = '.$ip_address_info->geoplugin_city.'<br/>'; echo 'Region = '.$ip_address_info->geoplugin_region.'<br/>'; echo 'Latitude = '.$ip_address_info->geoplugin_latitude.'<br/>'; echo 'Longitude = '.$ip_address_info->geoplugin_longitude.'<br/>'; echo 'Timezone = '.$ip_address_info->geoplugin_timezone.'<br/>'; echo 'Continent Code = '.$ip_address_info->geoplugin_continentCode.'<br/>'; echo 'Continent Name = '.$ip_address_info->geoplugin_continentName.'<br/>'; echo 'Timezone = '.$ip_address_info->geoplugin_timezone.'<br/>'; echo 'Currency Code = '.$ip_address_info->geoplugin_currencyCode; } ?>
Result
Country Name = India Country Code = IN City = Rajkot Region = Gujarat Latitude = 22.2916 Longitude = 70.7932 Timezone = Asia/Kolkata Continent Code = AS Continent Name = Asia Timezone = Asia/Kolkata Currency Code = INR
For Proxy Website – php get ip address
Country Name = United States Country Code = US City = Region = Latitude = 37.751 Longitude = -97.822 Timezone = America/Chicago Continent Code = NA Continent Name = North America Timezone = America/Chicago Currency Code = USD
Also Check : What is my screen resolution?
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.