require_once 'Net/IPv4.php';
bool validateIP (string $ip_addr, string $cidr_block)
bool validateIP
Determines whether or not the supplied IP address is within the supplied network.
Example 48-1. Checking if a IP adress is contained in a network
<?php require 'Net/IPv4.php'; $ip = '10.11.12.13'; $net1 = '10.0.0.1/8'; $net2 = '127.0.0.1/8'; echo Net_IPv4::ipInNetwork($ip, $net1) // bool(true) echo Net_IPv4::ipInNetwork($ip, $net2) // bool(false) ?>
This function can be called statically.