Page MenuHomeDevCentral

IP.php
No OneTemporary

<?php
declare(strict_types=1);
namespace Keruald\OmniTools\Network;
class IP {
public static function isIP (string $ip) : bool {
return self::isIPv4($ip) || self::isIPv6($ip);
}
public static function isIPv4 (string $ip) : bool {
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
}
public static function isIPv6 (string $ip) : bool {
return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
}
public static function isLoopback (string $ip) : bool {
$ranges = IPRange::getLoopbackRanges();
foreach ($ranges as $range) {
if ($range->contains($ip)) {
return true;
}
}
return false;
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Feb 28, 21:39 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2436109
Default Alt Text
IP.php (756 B)

Event Timeline