Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home PHP PHP Ip to Country

PHP Ip to Country

This example below will tell you the country name and country code based on IP Address.

First, you need to download the latest GeoLite Country Binary Forma from Maxmind, the database is FREE and should be updated monthly.

After that, you also need to download Pure PHP module (geoip.inc) from Maxmind.

Below is the source code:

[php] <?php

include("geoip.inc");

$gi = geoip_open(dirname(__FILE__) . "/GeoIP.dat",GEOIP_STANDARD);

$your_ip = $_SERVER[‘REMOTE_ADDR’];

echo "Your IP Address: " . $your_ip . "<br>You come from <b>" . geoip_country_code_by_addr($gi, $your_ip) . "</b> – <b>" . geoip_country_name_by_addr($gi, $your_ip) . "</b><br>";

echo geoip_country_code_by_addr($gi, "24.24.24.24") . "<br>" . geoip_country_name_by_addr($gi, "24.24.24.24") . "<br>"; //US United States
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "<br>" . geoip_country_name_by_addr($gi, "80.24.24.24") . "<br>"; //ES Spain

geoip_close($gi);

?>

[/php]

+ Download this example
+ View Demo

Mar 5, 2011Hoan Huynh
Google Ad Planner APILinux CentOS view live website access log with tail command
You Might Also Like:
  • PHP IP Address To Country City Region Latitude And Longitude
  • Facebook Like Button And Recommend Button With fb:like, iframe and html5
  • How To Track Website With Multiple Google Analytisc Accounts
  • Get WOEID Of A City Name From IP Address With PHP
  • Free Online Tools Get IP Address Location, Organization, ISP, Hostname, Country
  • PHP Get Image Width And Height
  • Accessing Websites Via Another Country Internet Connection
  • PHP measure/ calculate execution time of loading page
  • PHP Check If User Like Facebook Page
  • Facebook Load User Profile Via Graph API And FQL Query
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

11 years ago PHPGeoIP, ip address, Maxmind211
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,542 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,885 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,736 views
JQuery Allow only numeric characters or only alphabet characters in textbox
15,059 views
C# Read Json From URL And Parse/Deserialize Json
11,789 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development