geoip_record_by_name returns nothing?

时光怂恿深爱的人放手 提交于 2019-12-10 12:09:14

问题


I tried this tutorial http://tech.cibul.net/install-maxminds-geoip-ip-database-on-ubuntu-for-php/ and did everything from it. Compiled the geoip module and also the php extension on my Ubuntu 11.10 installation.

I also tried this more simpler terminal command

(sudo) apt-get install php5-geoip 

And it showed successful installation but when I try

geoip_record_by_name('127.0.0.1')

and it still gives nothing, i.e. no array at all.


回答1:


Try a different IP address - for example 111.111.111.111 as you are checking your localhost (127.0.0.1) - it may not run locally anyway.

See geoip_record_by_nameDocs:

Returns the associative array on success, or FALSE if the address cannot be found in the database.

You get back FALSE because the address was not found in the database.




回答2:


There is important discussion on this subject at https://bugs.php.net/bug.php?id=59753

The problem with this function is that it returns a "PHP Notice" when a address can not be found.

In plain the behavior this function take on normal internal address that is not expected to return location ( record ) from its database is to return "false" that is good and expected, but additional it send "PHP Notice" that is normally used to report real coding or library problems, but not expected results.



来源:https://stackoverflow.com/questions/9633877/geoip-record-by-name-returns-nothing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!