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 ipInNetwork ( string $ip , string $cidr_block )

Description

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

Example

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.

Calculates network information based on an IP address and netmask. (Previous) Net_IPv6 (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.