Ip Address is a fingerprint of each Computer on Internet. It enables your computer to connect with other computers. we can also get your details of location from your Ip Address. By Identifying the Geo Location of visitor we can show specific part of website to the visitor, Enable/Disable payment methods and more. How you can Identify Location of visitor using His/Her Ip Address? In this article we will learn to get Ip Address of visitor using his Ip Address using ip-apiin PHP.

Get Location From Ip Address-php

Get Your Exact Location using ip Address with IP-API In PHP

There are so many APIs provides accurate Location from Ip Address but i would like to recommend ip-api API. I am using ip-api service for more than a year and i have never face any issues. It’s Accurate, Provides well support and Never have downtime. ip-api is free for daily number of requests you can purchase it’s premium Plan to get more requests.

 Demo Download

Directory Structure

index.php

Inject class/ip-api.php into index.php and call getLocation() function. $location variable holds location array includes City, State and Country of visitor.



ip-api.php

Holds two PHP functions getIpAddres() and getLocation(). getIpAddres() fuction returns the Ip Address of visitor and getLocation() will send CURL request to get Current Address. We need Enable CURL extension from PHP Config.

Now, run index.php into web browser. It will fetch all the details of location and show on the screen.

 

Read More:

Composer – Dependency manager for PHP

Create a RESTful Web Service API with Slim

How To Integrate Stripe Payment Gateway Using PHP and JavaScript

sFileTypeChecker – JQuery Plugin To Validate Input File

sSwitch – JQuery Toggle Button Plugin For Sliding Toggle Switches

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">