Home > php教程 > php手册 > php查询IP段的所有IP地址

php查询IP段的所有IP地址

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:38:31
Original
2634 people have browsed it

php查询IP段的所有IP地址 此代码好像只能在win上运行。 我找了好多天才找到的可以使用的。 AD: http://www.0907.org/新建立的网站目录, 您可以去这里免费提交您的网站提高收录! 无 http://www.0907.org/ 新建立的网站目录,您可以去这里免费提交您的网站提

php查询IP段的所有IP地址
此代码好像只能在win上运行。
我找了好多天才找到的可以使用的。
AD:
http://www.0907.org/  新建立的网站目录,
您可以去这里免费提交您的网站提高收录!
http://www.0907.org/  新建立的网站目录,
您可以去这里免费提交您的网站提高收录!
Copy after login
header("Content-type: text/html; charset=utf-8"); 
function cidr($ip_addr_cidr) {
$ip_arr = explode('/', $ip_addr_cidr);
$dotcount = substr_count($ip_arr[0], ".");
$padding = str_repeat(".0", 3 - $dotcount);
$ip_arr[0].=$padding;
$bin = '';
for($i=1;$i<=32;$i++) {
   $bin .= $ip_arr[1] >= $i ? '1' : '0';
}
$ip_arr[1] = bindec($bin);
$ip = ip2long($ip_arr[0]);
$nm = ip2long($ip_arr[1]);
$nw = ($ip & $nm);
$nm1= (~$nm);
$bc = $nw  | $nm1;
echo "此IP段包含: " . ($bc - $nw - 1) . "个IP地址<BR>";
echo "可用IP范围: " . long2ip($nw + 1) . " 至 " . long2ip($bc - 1)  . "<BR>";
ECHO'可用IP列表:<BR>';

ECHO'<textarea  style="width:170;height:200">';
for ($ii = long2ip($nw - 1); $ii <long2ip($bc); $ii++) {
    echo $ii."\n";
}
ECHO '</textarea>';
}
echo cidr("192.168.37.215/27");

?>
Copy after login
php查询IP段的所有IP地址
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template