public function GeoIpHandlerV1::countryCode in GeoIP API 7.2
Returns the ISO 3166-2 country code for a given IP.
Defaults to using the current user's IP if not specified.
Parameters
string $ip: The ip to resolve.
Return value
string|FALSE Country code or FALSE on failure. Code is always upper case.
Overrides GeoIpHandlerInterface::countryCode
1 call to GeoIpHandlerV1::countryCode()
- GeoIpHandlerV1::rawRecord in src/
GeoIpHandlerV1.php - Returns an array of all information related the ip.
File
- src/
GeoIpHandlerV1.php, line 134 - The GeoIP API handler for version 1 - legacy.
Class
Namespace
Drupal\geoipCode
public function countryCode($ip = NULL) {
try {
return strtoupper(geoip_country_code_by_addr($this
->getReader(), $ip));
} catch (\Exception $e) {
return FALSE;
}
}