Checks whether the specified IP address presents the expected type of IP address (non-masked IP address, masked IP address, masked IP range, etc.).
Syntax
public static function ip_address_and_mask ($ip_address, $ip_mask, $valid)
Parameters
ip_address
A string value that specifies the IP address used to specify a valid subnet.
ip_mask
A string value that specifies the IP mask used to specify a valid subnet.
valid
A string value that specifies the validation rule to apply. Is set to IP_ADDRESS_ANY by default. The following validation rules are available:
Returns
A boolean which is true if the specified IP address and IP mask are not 0.0.0.0 and the rule applied to them succeeds. Otherwise returns false.
Remarks
This function applies the selected validation rule(s) to the combination of the IP address and IP mask to check whether the IP address really belongs to the expected type (a non-masked IP address, a masked IP address, an IP range, etc.).
123.123.0.0/16 is a range of addresses, but 123.123.0.1/16 is a particular IP address in a class B network.123.123.123.1/32 or 123.123.123.1/255.255.255.255. The rule fails if the IP address has '0' bits in its host part, e.g. 123.123.0.0/16, or if it has all '1' bits in the host part (a broadcast address), e.g. 123.123.123.255/255.255.255.0. 123.123.123.123.