What are the location detecting techniques for IP addresses?
I know to look at the
$_SERVER[\'HTTP_ACCEPT_LANGUAGE\'] (not accurate but mostly useful to
If the geolocation functionality is not a big requirement for your project, you can use something as simple as this:
$geotxt='';
$dt=json_decode(@file_get_contents('https://freegeoip.net/json/'.$_SERVER['REMOTE_ADDR']));
if ($dt!=null) $geotxt=$dt->country_name.', '.$dt->region_name.', '.$dt->city;
echo $geotxt;
You have to take into account that freegeoip has a limit of 10k request/hour.