http://www.maxmind.com/app/geoip_country
代碼: 選擇全部
$ip ='192.168.0.1';
$array = explode('.', $ip);
$sum = $array[0] * 16777216 + $array[1] * 65536 + $array[2] * 256 + $array[3];
/* 然後取出的 SQL 語法: */
"SELECT `country`, `name` FROM `ip_country` WHERE $sum BETWEEN `begin_num` AND `end_num` LIMIT 1
代碼: 選擇全部
<?php
$ipv4 = '192.168.0.1';
$result = sprintf("%u", ip2long($ipv4));
?>