public function GeoIpHandlerV2::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/
GeoIpHandlerV2.php, line 181 - The GeoIP API handler for version 2.
Class
Namespace
Drupal\geoipCode
public function cityName($ip = NULL) {
try {
return $this
->record($ip)->city->name;
} catch (\Exception $e) {
return FALSE;
}
}