PHP Script - Subnet Info ======================== This is a php function for getting subnet information. Public domain ******************************************************************************** ### Syntax subnet_info($network, $request); $network can be "ip/netmask" or "ip/prefix" $request can be host number or one of this strings: ip, netmask, wildcard, prefix, netid, broadcast, ip_bin, netmask_bin, netid_bin, broadcast_bin, hosts ******************************************************************************** ### Usage example $network = "192.168.50.70/255.255.255.240"; echo subnet_info($network,"ip")." : IP\n"; echo subnet_info($network,"netmask")." : Netmask\n"; echo subnet_info($network,"wildcard")." : Wildcard\n"; echo subnet_info($network,"networkid")." : Network ID\n"; echo subnet_info($network,"broadcast")." : Broadcast\n"; echo subnet_info($network,"ip_bin")." : IP binary\n"; echo subnet_info($network,"netmask_bin")." : Netmask binary\n"; echo subnet_info($network,"networkid_bin")." : NetID binary\n"; echo subnet_info($network,"broadcast_bin")." : Bradcast binary\n"; echo subnet_info($network,"prefix_bin")." : Prefix binary\n"; echo subnet_info($network,"prefix")." : Prefix\n"; echo subnet_info($network,"hosts")." : Hosts\n"; echo subnet_info($network,"12")." : Host number 12 \n"; echo "\n"; $network = "192.168.50.70/20"; echo subnet_info($network,"ip")." : IP\n"; echo subnet_info($network,"netmask")." : Netmask\n"; echo subnet_info($network,"wildcard")." : Wildcard\n"; echo subnet_info($network,"networkid")." : Network ID\n"; echo subnet_info($network,"broadcast")." : Broadcast\n"; echo subnet_info($network,"ip_bin")." : IP binary\n"; echo subnet_info($network,"netmask_bin")." : Netmask binary\n"; echo subnet_info($network,"networkid_bin")." : NetID binary\n"; echo subnet_info($network,"broadcast_bin")." : Bradcast binary\n"; echo subnet_info($network,"prefix_bin")." : Prefix binary\n"; echo subnet_info($network,"prefix")." : Prefix\n"; echo subnet_info($network,"hosts")." : Hosts\n"; echo subnet_info($network,"1200")." : Host number 1200 \n"; echo "\n"; ******************************************************************************** ### Output example 192.168.50.70 : IP 255.255.255.240 : Netmask 0.0.0.15 : Wildcard 192.168.50.64 : Network ID 192.168.50.79 : Broadcast 11000000.10101000.00110010.01000110 : IP binary 11111111.11111111.11111111.11110000 : Netmask binary 11000000.10101000.00110010.01000000 : NetID binary 11000000.10101000.00110010.01001111 : Bradcast binary 11111111.11111111.11111111.11110000 : Prefix binary 28 : Prefix 16 : Hosts 192.168.50.75 : Host number 12 192.168.50.70 : IP 255.255.240.0 : Netmask 0.0.15.255 : Wildcard 192.168.48.0 : Network ID 192.168.63.255 : Broadcast 11000000.10101000.00110010.01000110 : IP binary 11111111111111111111000000000000 : Netmask binary 11000000.10101000.00110000.00000000 : NetID binary 11000000.10101000.00111111.11111111 : Bradcast binary 11111111111111111111000000000000 : Prefix binary 20 : Prefix 4096 : Hosts 192.168.52.175 : Host number 1200 ******************************************************************************** ### subnet_info function ******************************************************************************** _BY: Pejman Moghadam_ _TAG: php_ _DATE: 2012-07-02 18:14:16_