Wednesday, 11 September 2013

Get the continent/country or location of user in php?

Get the continent/country or location of user in php?

Is possible to get the continent from where the user it is accessing a
site? I do know i can get the language of the browser like this:::
<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
case "fr":
//echo "PAGE FR";
include("index_fr.php");//include check session FR
break;
case "it":
//echo "PAGE IT";
include("index_it.php");
break;
case "en":
//echo "PAGE EN";
include("index_en.php");
break;
default:
//echo "PAGE EN - Setting Default";
include("index_en.php");//include EN in all other cases of
different lang detection
break;
}
?>
REF
Also i do know there is something php function call ->
geoip_continent_code_by_name which if a pass a string with the host name
it will return me:
Code Continent name
AF Africa
AN Antarctica
AS Asia
EU Europe
NA North america
OC Oceania
SA South america
But this only returns me the host name, so is there any way to get the
same result but for the user who is accessing the site? or is even
possible to do?

No comments:

Post a Comment