简体   繁体   English

mod_geoip2和php pecl-geoip:如何通过IP地址查询?

[英]mod_geoip2 and php pecl-geoip: how can i query by ip address?

how can i query the geoip database using php? 如何使用php查询geoip数据库?

I have apache2 with mod_geoip2 installed and the pecl extension geoip PHP 5.3. 我有安装了mod_geoip2的apache2和pecl扩展名geoip PHP 5.3。

i want to search the country of the ip address i have as a parameter, not to query my own ip address. 我想搜索我作为参数的IP地址的国家/地区,而不是查询自己的IP地址。

thanks 谢谢

I suppose the geoip_country_code_by_name function could do the trick : it takes a hostname or IP address as a parameter, and returns the corresponding country-code. 我想geoip_country_code_by_name函数可以解决问题:它将主机名或IP地址作为参数,并返回相应的国家/地区代码。

If you pass the IP address you have for that parameter (and not your own) , it should do what you're asking for. 如果传递的是该参数的IP地址(而不是您自己的IP地址 ,则它应该执行您所要的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM