GeoIp2 extends AbstractGeoIp
GeoIP v2 integration
Table of Contents
Properties
| $reader | |
| $records |
Methods
| __construct() | Create a new GeoIP instance using the given database file |
| getCountryCode() | Returns the 2-character country code where the IP resides |
| getCountryName() | Returns the name of the country where the IP resides |
| getIp() | Returns the currently set IP address |
| getLocation() | Fetches an array of information about the location of the IP address, including longitude and latitude. |
| getOrganization() | Would get the organization or ISP that owns the current IP address. However this information is not available from the GeoIp2 city model |
| getRegion() | Get the region (e.g. state) of the given IP address. |
| setIp() | Sets the Ip address to use for all suybsequent queries |
Methods
__construct()
Create a new GeoIP instance using the given database file
public
__construct(string $database_file) : mixed
Parameters
- $database_file : string
-
The full path to the database file
getCountryCode()
Returns the 2-character country code where the IP resides
public
getCountryCode() : string
Return values
string —The 2-character country code where the IP resides
getCountryName()
Returns the name of the country where the IP resides
public
getCountryName() : string
Return values
string —The name of the country where the IP resides
getIp()
Returns the currently set IP address
public
getIp() : string
Return values
string —The IP given in $ip, or the user's IP if $ip was null.
getLocation()
Fetches an array of information about the location of the IP address, including longitude and latitude.
public
getLocation() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of information about the location of the IP address
getOrganization()
Would get the organization or ISP that owns the current IP address. However this information is not available from the GeoIp2 city model
public
getOrganization() : string
Return values
stringgetRegion()
Get the region (e.g. state) of the given IP address.
public
getRegion() : string
Return values
string —The region the IP address resides in
setIp()
Sets the Ip address to use for all suybsequent queries
public
setIp(string $ip) : mixed
Parameters
- $ip : string
-
The Ip address to set