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;
}
?>