Get country location of an IP with native PHP

前端 未结 8 1062
野性不改
野性不改 2020-12-23 16:46

Read on before you say this is a duplicate, it\'s not. (as far as I could see)

I want to get the county code in php from the client.

Yes I know you can do th

8条回答
  •  暖寄归人
    2020-12-23 17:01

    MaxMind provide a free PHP GeoIP country lookup class (there is also a free country+city lookup one).

    The bit you want is what is mentioned under "Pure PHP module". This doesn't require you to install anything, or be dependent on them, nor does it need any special PHP modules installed. Just save the GeoIP data file somewhere, then use their provided class to interact with it.

提交回复
热议问题