You are here

function geoip_city_name in GeoIP API 7.2

Returns the city data 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, defaults to the current users ip.

Return value

string|FALSE The city name or FALSE on error.

Related topics

1 call to geoip_city_name()
geoip_admin_settings in ./geoip.admin.inc
Menu callback and form builder for admin/settings/geoip.

File

./geoip.module, line 336
API for using the MaxMind GeoLite Country database.

Code

function geoip_city_name($ip = NULL) {
  $ip = $ip ? $ip : geoip_ip_address();
  if ($gi = geoip_instance()) {
    return $gi
      ->cityName($ip);
  }
  return FALSE;
}