2.8.18. Determining the visitor's country in PHP
Each site request contains a special header HTTP_GEOIP_COUNTRY_CODE
which contains the visitor's two-letter country code (ISO 3166). The country is determined based on the visitor's IP address as reported by MaxMind GeoLite.
You can get the two-letter country code in PHP from the server variable $_SERVER['HTTP_GEOIP_COUNTRY_CODE']
.