IP2Long和Long2IP函数的PHP实现-PHP源码
php代码:
function IP2Long($ip) {
$ips = explode('.', $ip);
if(count($ips) != 4) {
return false;
}
return ($ips[0] << 24) + ($ips[1] << 16) + ($ips[2] << 8) + $ips[3];
}
function Long2IP($int) {
$ip1 = $ipint >> 24;
$ip2 = ($ipint >> 16) & 255;
$ip3 = ($ipint >> 8) & 255;
$ip4 = $ipint & 255;
return $ip1.'.'.$ip2.'.'.$ip3.'.'.$ip4;
}
/php/36095.htmlwww.phpzy.comtrue/php/36095.htmlTechArticleIP2Long和Long2IP函数的PHP实现-PHP源码 php代码: function IP2Long($ip) { $ips = explode(., $ip); if(count($ips) != 4) { return false; } return ($ips[0] > 24; $ip2 = ($ipint >> 16) $ip3 = ($ipint >> 8) $ip4 = $ipint return $ip1...$...
PHP之友评论