所以我有以下两个IP范围
import
{
AfterContentChecked,
Directive,
HostBinding,
HostListener,
Input,
OnInit
} from '@angular/core';
@Directive({
selector: '[imgspinloader]'
})
export class ImageSpinloaderDirective
{
private defaultSrc: string = "assets/img/user-image-invitation-2x.png";
@Input() @HostBinding() src;
@Input() @HostBinding("class.img-loading") isLoading: boolean;
@HostListener('load') complete()
{
this.isLoading = false;
}
@HostListener('error') onError()
{
this.src = this.defaultSrc;
this.isLoading = false;
}
}
我可以用什么php函数来区分ipv4范围和ipv6范围
需要这样的东西
2a02:c78::/29
2.120.0.0/13
答案 0 :(得分:1)
此解决方案的功劳归于用户@deceze
function ip_range_type($range_ip)
{
if (strpos($range_ip, ':') !== false) {
//if ip range provided is ipv6 then
echo "range provided is ipv6";
} else {
//if ip range provided is ipv4 then
echo "range provided is ipv4";
}
}
$range_ip = "2a02:c78::/29";
ip_range_type($range_ip);
答案 1 :(得分:0)
IP地址具有很多范围,例如全部IPv4 Ranges,其网络地址和CIDR相同,您也可以检查IPv6 Ranges。 check IPv4 or IPv6 Range已在此处{{3}}高效地解释了您的问题。