Categories
FAQ

Netmask conversions (bitmask / cidr / hex / binary)

If you have ever needed to know what a netmask looks like expressed in some other format this table of equivalents should help. It contains common IPv4 netmasks expressed in four different formats.

Bitmask (Bits)Dotted DecimalHexadecimalBinary
/00.0.0.00x0000000000000000 00000000 00000000 00000000
/1128.0.0.00x8000000010000000 00000000 00000000 00000000
/2192.0.0.00xc000000011000000 00000000 00000000 00000000
/3224.0.0.00xe000000011100000 00000000 00000000 00000000
/4240.0.0.00xf000000011110000 00000000 00000000 00000000
/5248.0.0.00xf800000011111000 00000000 00000000 00000000
/6252.0.0.00xfc00000011111100 00000000 00000000 00000000
/7254.0.0.00xfe00000011111110 00000000 00000000 00000000
/8255.0.0.00xff00000011111111 00000000 00000000 00000000
/9255.128.0.00xff80000011111111 10000000 00000000 00000000
/10255.192.0.00xffc0000011111111 11000000 00000000 00000000
/11255.224.0.00xffe0000011111111 11100000 00000000 00000000
/12255.240.0.00xfff0000011111111 11110000 00000000 00000000
/13255.248.0.00xfff8000011111111 11111000 00000000 00000000
/14255.252.0.00xfffc000011111111 11111100 00000000 00000000
/15255.254.0.00xfffe000011111111 11111110 00000000 00000000
/16255.255.0.00xffff000011111111 11111111 00000000 00000000
/17255.255.128.00xffff800011111111 11111111 10000000 00000000
/18255.255.192.00xffffc00011111111 11111111 11000000 00000000
/19255.255.224.00xffffe00011111111 11111111 11100000 00000000
/20255.255.240.00xfffff00011111111 11111111 11110000 00000000
/21255.255.248.00xfffff80011111111 11111111 11111000 00000000
/22255.255.252.00xfffffc0011111111 11111111 11111100 00000000
/23255.255.254.00xfffffe0011111111 11111111 11111110 00000000
/24255.255.255.00xffffff0011111111 11111111 11111111 00000000
/25255.255.255.1280xffffff8011111111 11111111 11111111 10000000
/26255.255.255.1920xffffffc011111111 11111111 11111111 11000000
/27255.255.255.2240xffffffe011111111 11111111 11111111 11100000
/28255.255.255.2400xfffffff011111111 11111111 11111111 11110000
/29255.255.255.2480xfffffff811111111 11111111 11111111 11111000
/30255.255.255.2520xfffffffc11111111 11111111 11111111 11111100
/31255.255.255.2540xfffffffe11111111 11111111 11111111 11111110
/32255.255.255.2550xffffffff11111111 11111111 11111111 11111111
Categories
How to

How to get a file extension with PHP

The following script makes it more easy to get the file extension from a file name:

In case you have the ability to use mime type detection, you could combine it with the above function to validate if the extension is valid for the content of the file.