Manuel Pear

Net_IPv4::ipInNetwork()

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

Synopsis

  1. <?php
  2. require_once 'Net/IPv4.php
  3. ?> 

bool validateIP (string $ip_addr, string $cidr_block)

Description

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

Exemple

Exemple 54-1. Checking if a IP adress is contained in a network

  1. <?php
  2.  
  3. require 'Net/IPv4.php';  
  4.  
  5. $ip = '10.11.12.13';  
  6. $net1 = '10.0.0.1/8';  
  7. $net2 = '127.0.0.1/8';  
  8.  
  9. echo Net_IPv4::ipInNetwork($ip, $net1) // bool(true)
  10. echo Net_IPv4::ipInNetwork($ip, $net2) // bool(false)
  11.  
  12. ?> 

Note

Cette fonction peut être appelée de façon statique.


Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Bretagne - php - Moto - Kit graphique