You are here

public function GeoIpHandlerV1::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/GeoIpHandlerV1.php, line 103
The GeoIP API handler for version 1 - legacy.

Class

GeoIpHandlerV1

Namespace

Drupal\geoip

Code

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