3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //Используется так: function net_match ( $network , $ip ) { $ip_arr = explode ( '/' , $network ); $network_long = ip2long ( $ip_arr [ 0 ]); $x = ip2long ( $ip_arr [ 1 ]); $mask = long2ip ( $x ) == $ip_arr [ 1 ] ? $x : 0xffffffff << ( 256 - $ip_arr [ 1 ]); $ip_long = ip2long ( $ip ); // echo ">".$ip_arr[1]."> ".decbin($mask)."\n"; return ( $ip_long & $mask ) == ( $network_long & $mask ); } echo net_match ( '193.168.0.0/143', '192.168.0.144' );
Output for 4.3.0 - 7.3.0rc4
1