/php-geoip

Retrieves the geolocation of IP addresses using RDAP and hostnames.

Primary LanguagePHPMIT LicenseMIT

GeoIP

PHP Library for retrieving the geolocation of ip addresses.

Usage

All you need to do is including "geoip.php":

include  "geoip.php";

GeoIP consists of 4 functions:

  • get_country_by_host($host)
  • get_country_by_ip($ip)
  • get_country_by_rdap($query)
  • get_continent_by_country($country)

What they do is already obvious by their name, the return value is either a two character country/continent code or null if the location is unknown.

"get_country_by_rdap($query)" uses the RDAP protocol for getting the ip address' location, works for all european ones.

Affiliated projects