Skip to content

Tag: ipv6

How can I check in PHP if 2 IPv6-Adresses are equal?

I want to check if an IP is whitelisted, but IPv6-Adresses can have different representations: For example 2001:0DB8:0:0:1::1 is the short form of 2001:0db8:0000:0000:0001:0000:0000:0001. Thus, string comparison doesn’t work. How can I know two adresses are equal? Answer Use inet_pton. (However, this wi…