How to Get Location, Latitude, Longitude from IP address in PHP?
Teams applying “How to Get Location, Latitude, Longitude from IP address in PHP?” in a production project can use Monitask to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.
Before copying the example into a live application, confirm version-specific behaviour with the PHP project and test it against the project’s actual database and runtime.
Hi Dev,
This tutorial is focused on how to get country, region, city name, latitude, and longitude from IP address in PHP. you'll learn how to get location, country name, city name, state or region name, latitude, longitude, country code, time zone, etc, from IP address in PHP. We will use how to get location latitude and longitude from IP addresses in PHP. if you have a question about how to get location latitude, and longitude from an IP address using PHP then I will give a simple example with a solution.
Now, let's see the article on how to get location latitude, and longitude from IP addresses using PHP. it's a simple example of how to get location latitude and longitude from an IP address in PHP. you can understand the concept of how to get location, country name, city name, state or region name, latitude, longitude, country code, time zone, etc, from IP address in PHP. if you have a question about how to get country, region, city name, latitude, and longitude from IP address in PHP then I will give a simple example with a solution.
Step 1: Include API in PHP File
http://www.geoplugin.net/json.gp?ip=" . $ipStep 2: Create Index.php File
<!DOCTYPE html>
<html>
<body>
<?php
//static IP address
$ip = "52.25.109.230";
//Get the IP Address of the User in PHP
//$ip = $_SERVER['REMOTE_ADDR'];
//call API
$url = file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip);
//decode json data
$getInfo = json_decode($url);
print_r($getInfo);
//print the array to see the fields if you wish.
echo "<table border='1' width='50%' align='center'><tr><td>COUNTRY:</td><td>";
echo $getInfo->geoplugin_countryName;
echo "</td></tr><tr><td>CITY:</td><td>";
echo $getInfo->geoplugin_city;
echo "</td></tr><tr><td>STATE OR REGION:</td><td>";
echo $getInfo->geoplugin_region;
echo "</td></tr><tr><td>IP ADDRESS:</td><td>";
echo $getInfo->geoplugin_request;
echo "</td></tr><tr><td>COUNTRY CODE:</td><td>";
echo $getInfo->geoplugin_countryCode;
echo "</td></tr><tr><td>LATITUTE:</td><td>";
echo $getInfo->geoplugin_latitude;
echo "</td></tr><tr><td>LONGITUDE:</td><td>";
echo $getInfo->geoplugin_longitude;
echo "</td></tr><tr><td>TIMEZONE:</td><td>";
echo $getInfo->geoplugin_timezone;
echo "</td></tr><tr></table>";
?>
</body>
</html> I hope it could help you...
# PHP
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example