Closed daigo75 closed 9 years ago
On recent versions of this library, calling $reader->country(...)
with a City database should throw a BadMethodCallException
. Use the city()
method instead.
For instance, this works for me:
$reader = new Reader("/usr/local/share/GeoIP/GeoLite2-City.mmdb");
echo $reader->city('87.65.122.63')->country->isoCode;
That's correct, if I use city
and then country
it works. However, I'm worried about what would happen if the city cannot be determined. Do I still get a record with a country object?
The methods on the reader object are for the database type, not the field type. Using the city method will return any data that is in the City database for that IP.
I see. If I understand it correctly, I will get all the information available for the IP address, which means:
Is that correct?
Yes.
Perfect, thanks.
I'm working on a project where we are required to geolocate visitors' country and, in some cases, visitors' city as well. Due to that, I switcher from the Country database to the City one, but I encountered an unexpected behaviour, described below:
Questions