http://chir.ag/projects/geoiploc/
您好,我正在尝试进行设置,但是每当我使用include("geoiploc.php");
该页面时,页面都是空白的,并且每当我删除时,include("geoiploc.php");
我只会看到我的 IP 地址。我已将 geoiploc.php 和 index.php 上传到可以运行 PHP 的虚拟主机。
如果有任何其他更简单的方法可以通过 IP 或任何其他方式显示国家名称,那是什么?请我需要这个快
所以正如我所说,它只在我删除include("geoiploc.php");
为什么时显示我的IP?
你需要这个库:http ://chir.ag/projects/geoiploc/autogen/geoiploc.tar.gz这是运行脚本的代码:
include("geoiploc.php"); // Must include this
// ip must be of the form "192.168.1.100"
// you may load this from a database
$ip = $_SERVER["REMOTE_ADDR"];
echo "Your IP Address is: " . $ip . "<br />";
echo "Your Country is: ";
// returns country code by default
echo getCountryFromIP($ip);
echo "<br />\n";
// optionally, you can specify the return type
// type can be "code" (default), "abbr", "name"
echo "Your Country Code is: ";
echo getCountryFromIP($ip, "code");
echo "<br />\n";
// print country abbreviation - case insensitive
echo "Your Country Abbreviation is: ";
echo getCountryFromIP($ip, "AbBr");
echo "<br />\n";
// full name of country - spaces are trimmed
echo "Your Country Name is: ";
echo getCountryFromIP($ip, " NamE ");
echo "<br />\n";