You are here

public function GeoIpHandlerV1::cityName in GeoIP API 7.2

The city name for a given IP.

Defaults to using the current user's IP if not specified. This function only works with the city level database and will return false in all other cases.

Parameters

string $ip: The ip to resolve.

Return value

string|FALSE The city name or FALSE on failure (e.g. the country db is used).

Overrides GeoIpHandlerInterface::cityName

File

src/GeoIpHandlerV1.php, line 188
The GeoIP API handler for version 1 - legacy.

Class

GeoIpHandlerV1

Namespace

Drupal\geoip

Code

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