标签:
function ip_binay($ip) { $ip_array = explode(".",$ip); $t = ‘‘; foreach($ip_array as $v) { $tmp = decbin($v); $tmp_len = strlen(decbin($v)); if($tmp_len < 8) $t .= str_repeat( "0",(8 - $tmp_len) ).$tmp; else $t .= $tmp; } return $t; } $server_ip = "0.0.0.0"; //地址段 $mask_ip = "0.0.0.0"; //子网掩码 $client_ip=‘192.168.1.11‘;//客户端ip $D=ip_binay($client_ip); $is_ip_in=0; $M = ip_binay($mask_ip); $temp = $D & $M; $N = ip_binay( $server_ip ); if( $temp == $N ){ $is_ip_in=1; } if($is_ip_in){ echo "你的ip处于该网络下!"; }else{ echo ‘NO‘; }
标签:
原文地址:http://www.cnblogs.com/rnckty/p/4422210.html