Get Visitor Information by IP Address in PHP – How to Get The IP Address in PHP?

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("".$ip_address));

Complete PHP Code: Get Visitor Information by IP Address in PHP

$ip_address_info = @json_decode(file_get_contents("".$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;


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

Also Read This πŸ‘‰   .htaccess file Not Working on server with PHP - Fix

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?