Login +

Documentation

SLS_String::isIpV6

Since SillySmart 1.0.7

Description

Check if the given string is a valid IPV6The regex matches the following IPv6 address forms. Note that these are all the same address:° full form of IPv6: "fe80:0000:0000:0000:0204:61ff:fe9d:f156"° drop leading zeroes: "fe80:0:0:0:204:61ff:fe9d:f156"° collapse multiple zeroes to :: in the IPv6 address: "fe80::204:61ff:fe9d:f156"° IPv4 dotted quad at the end: "fe80:0000:0000:0000:0204:61ff:254.157.241.86"° drop leading zeroes, IPv4 dotted quad at the end: "fe80:0:0:0:0204:61ff:254.157.241.86"° dotted quad at the end, multiple zeroes collapsed: "fe80::204:61ff:254.157.241.86"In addition, the regular expression matches these IPv6 forms:° locahost: "::1"° link-local prefix: "fe80::"° global unicast prefix: "2001::"
static bool isIpV6 ( string $string);

Parameters

  • string $string
    the string to test

Return

bool
true if the string match with an ipv6, else false

Exemples

  •  var_dump(SLS_String::isIpV6("2001:0660:7401:0200:0000:0000:0edf:bdd7"));
     // will produce : true
     var_dump(SLS_String::isIpV6("2001:660:7401:200::edf:bdd7"));
     // will produce : true
  •  var_dump(SLS_String::isIpV6("1111:2222:3333:4444::5555:"));
     // will produce : false

Comments

No comment on this function, be the first !

Add your comment

You must login/register to post a reply.