PHP code example of morsvox / ip-range-checker

1. Go to this page and download the library: Download morsvox/ip-range-checker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

morsvox / ip-range-checker example snippets


use IlkerMutlu\IPRangeChecker\Checker;

$ip = '192.168.0.22';
$checker = Checker::forIp($ip);

$checker->setRange([
    '192.168.0.1',
    '192.168.0.28'
]);

// $checker->check() will return true for IPs between
// 192.168.0.1 and 192.168.0.28
// 192.168.0.19 will return TRUE
// 192.168.1.41 will return FALSE

$checker->setRange('192.168.0.*');

// $checker->check() will return TRUE for IPs between
// 192.168.0.1 and 192.168.0.255
// 192.168.0.41 will return TRUE
// 192.168.1.41 will return FALSE

$checker->setRange('192.168.0.4-192.168.0.54');

// $checker->check() will return TRUE for IPs between
// 192.168.0.4 and 192.168.0.54
// 192.168.0.41 will return TRUE
// 192.168.0.61 will return FALSE

$checker->check();