Home > php教程 > php手册 > 计算是否处在同一子网下的php脚本

计算是否处在同一子网下的php脚本

WBOY
Release: 2016-06-13 10:22:03
Original
1086 people have browsed it

/*
如:192.16.1.13
与:255.255.255.0
进行,,与算,,要求出它为192.16.1.0
*/
$ip = "192.16.1.13";
echo get_net($ip,"255.255.255.0");

function get_net($ip,$hide="255.255.255.255") {
  $a = explode(".",$ip);
  $b = explode(".",$hide);

  for($i=0;$i    $r[$i] = (int)$a[$i] & (int)$b[$i];
  return join(".",$r);
}
?>

Related labels:
source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template