PHP IPv6工具(v6tools)是一个小型库,提供IPv6地址,子网和EUI64的验证。
<?php
require('v6tools/autoload.php');
if (!v6tools\Runtime::isIPv6Supported()) {
fprintf(STDERR, "No ipv6 support");
exit(-1);
}
$ip = new v6tools\EUI64('2a01:198:603:0:224:d6ff:fe18:618c');
echo $ip->getMacAddress();
// echos 00:24:d6:18:61:8c
$ip = new v6tools\Subnet('2001::/16');
$ip->isInSubnet('2001::1');
// returns true
$ip->isInSubnet('2000::1');
// return false