You are here

public function GeoIpHandlerV2::continentCode in GeoIP API 7.2

Returns the continent 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 Continent code or FALSE on failure. Code is always upper case.

Overrides GeoIpHandlerInterface::continentCode

File

src/GeoIpHandlerV2.php, line 102
The GeoIP API handler for version 2.

Class

GeoIpHandlerV2

Namespace

Drupal\geoip

Code

public function continentCode($ip = NULL) {
  try {
    return strtoupper($this
      ->record($ip)->continent->code);
  } catch (\Exception $e) {
    return FALSE;
  }
}