簡體   English   中英

Maxmind Geolitecity 數據庫中的 IP 地址表示

[英]IP address representation in the Maxmind Geolitecity database

我在 Mysql 數據庫中有 Maxmind Geolitecity 數據庫。

我可以看到像startIpNumendIpNum這樣的字段。

這些字段的值如下所示:startIpNum 為 16777216, 16777471startIpNum

我的 ip 是 115.184.126.186,如何轉換我的 ip 以匹配startIpNumendIpNum

按照 lmz 的建議使用 inet_aton(),或者在 php 中使用:

http://php.net/manual/en/function.ip2long.php

Note that this function returns an signed integer, meaning ranging from − 2,147,483,648 to 2,147,483,647, and I think the maxmind geoip database uses unsigned ints (0-4,294,967,295?) so you need to add 2,147,483,647 to it (2^31-1)

試試inet_aton中的 inet_aton function。

嘗試像這樣轉換它-

SELECT INET_ATON("115.184.126.186");

嘗試這樣的事情:

<?php 
 $ipadd="115.184.126.186";
 $ips = explode(".",$ipadd);
 $x=($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256);
 echo $x;
?>

只需將此修改為 function..

是代碼的結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM