Last active
January 14, 2019 08:38
-
-
Save hn-support/93d1d5d32f9fa8878881b1ce25eb047b to your computer and use it in GitHub Desktop.
How to use geoip data in php on hypernodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This script is a basic example of how to use GeoIP data in PHP. | |
It returns an overview of all available constants retrieved from the Maxmind GeoIP databases. | |
*/ | |
$elements = array( | |
"country_code" => getenv('GEOIP_COUNTRY_CODE'), | |
"country_code3" => getenv('GEOIP_COUNTRY_CODE3'), | |
"country_name" => getenv('GEOIP_COUNTRY_NAME'), | |
"city_country_code" => getenv('GEOIP_CITY_COUNTRY_CODE'), | |
"city_country_code3" => getenv('GEOIP_CITY_COUNTRY_CODE3'), | |
"city_country_name" => getenv('GEOIP_CITY_COUNTRY_NAME'), | |
"region" => getenv('GEOIP_REGION'), | |
"city" => getenv('GEOIP_CITY'), | |
"postal_code" => getenv('GEOIP_POSTAL_CODE'), | |
"city_continent_code" => getenv('GEOIP_CITY_CONTINENT_CODE'), | |
"latitude" => getenv('GEOIP_LATITUDE'), | |
"longitude" => getenv('GEOIP_LONGITUDE'), | |
); | |
echo "<pre>"; | |
foreach ($elements as $name => $data) { | |
printf("%-30s %s\n", $name, $data); | |
} | |
echo "</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment