Class networks

Net_CheckIP2 has a getClass method which helps the developer to determine if the IP is within an class A, B or C network.

In case getClass is unable to determine the class, or the IP is invalid, false is returned.

getClass

<?php
require_once 'Net/CheckIP.php';
$ip '127.0.0.1';

$classNetwork Net_CheckIP::getClass($ip);
if (
$classNetwork === false) {
    die(
'Unable to determine the class. The IP might be invalid also.');
}
switch (
$classNetwork) {
case 
Net_CheckIP2::CLASS_A:
    echo 
'Class A network.';
    break;
case 
Net_CheckIP2::CLASS_B:
    echo 
'Class B network.';
    break;
case 
Net_CheckIP2::CLASS_C:
    echo 
'Class C network.';
    break;
}
?>
From Net_CheckIP to Net_CheckIP2 (Previous) Net_CheckIP2::is*() (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.