ip block country
how can i determine the visitor country e.g us
becuase i want make each us visitor get his country language
1 Answer
ok its very easy, just you can depend on an api like this
http://api.hostip.info/country.php see the example:$country = file_get_contents(\'http://api.hostip.info/country.php\'); echo $country; This however will return your server location, since the IP would be set as your server IP. So you\'ll have to get the visitors IP via the $_SERVER[\"REMOTE_ADDR\"] which is available in PHP as a \"predefined variable\". Then append their IP to the country endpoint of their API. Example PHP:$api = \'http://api.hostip.info/country.php?ip=\'; $country = file_get_contents($api.$_SERVER[\'REMOTE_ADDR\']; echo $country; Posted: MacOS 1 of 1 people found this answer helpful. Did you? Yes No Ok super PHP code |
© Advanced Web Core. All rights reserved