You are here

public function GeoIpHandlerV2::countryName in GeoIP API 7.2

Returns the country name 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 name or FALSE on failure.

Overrides GeoIpHandlerInterface::countryName

File

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

Class

GeoIpHandlerV2

Namespace

Drupal\geoip

Code

public function countryName($ip = NULL) {
  try {
    return $this
      ->record($ip)->country->name;
  } catch (\Exception $e) {
    return FALSE;
  }
}