从php的IP地址中查找州,国家,城市的代码 [英] code for finding the state,country,city from the IP Adress in php

查看:250
本文介绍了从php的IP地址中查找州,国家,城市的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生, 我正在开发一个网站.我从中获取用户的IP地址.现在我想找到他们要输入的州,城市和国家.这意味着我要从用户的IP地址中找到州,国家和城市.我在php中需要的代码.你能帮我做到吗

Sir, I developing a site. In which i get the IP addresses of the users from where they are entered. Now i want to find the State,City and country from where they are entering.That means i want to find the state, country, city from the IP address of the user. the code i need in php. can you help me to do that

推荐答案

您是否使用过 geoip_region_by_name() 函数:

Have you looked at using the Geo IP module? For example, the geoip_region_by_name() function:

geoip_region_by_name() 函数将返回该国家和 对应于主机名的区域或 IP地址.

The geoip_region_by_name() function will return the country and region corresponding to a hostname or an IP address.

当前仅此功能 可供已购买产品的用户使用 商业版GeoIP地区版.一种 如果适当,将发出警告 找不到数据库.

This function is currently only available to users who have bought a commercial GeoIP Region Edition. A warning will be issued if the proper database cannot be located.

不同键的名称 返回关联数组为 如下:

The names of the different keys of the returning associative array are as follows:

  • 国家/地区代码"-两个字母的国家/地区代码(请参阅 geoip_country_code_by_name())
  • 地区"-地区代码(例如:加利福尼亚州的CA)
  • "country_code" -- Two letter country code (see geoip_country_code_by_name())
  • "region" -- The region code (ex: CA for California)

这篇关于从php的IP地址中查找州,国家,城市的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆