PEAR Manual
Prev |  | Next

# Net_IPv4::ipInNetwork()

Net_IPv4::ipInNetwork() -- Determines whether or not the supplied IP is within the supplied network.

## Synopsis

    require_once 'Net/IPv4.php';

``bool validateIP` (string $ip_addr, string $cidr_block)`

## Description

Determines whether or not the supplied IP address is within the supplied network.

## Example

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)
    ?>

## Note

This function can be called statically.

Prev | Home | Next
Net_IPv4::calculate() | Up | Net_IPv6