25 $length = strlen($string);
32 if ($string ===
'')
return '';
33 if ($length > 1 && $string[0] ===
'[' && $string[$length-1] ===
']') {
35 $ip = substr($string, 1, $length - 2);
37 if (
$valid ===
false)
return false;
42 $ipv4 = $this->ipv4->validate($string,
$config, $context);
56 $domainlabel =
"$an($and*$an)?";
58 $toplabel =
"$a($and*$an)?";
60 $match = preg_match(
"/^($domainlabel\.)*$toplabel\.?$/i", $string);
61 if (!$match)
return false;