I would like to have an input box where someone can input a domain and it will validate the domain then convert it to an IP, then validate the IP. If the IP doesn't validate it will echo none.
So, I'm wondering if this is the best way to do this, or is there a better way to do this?
$input = 'somedoaminhere.com';
$ValidIp = "/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/";
$parse = parse_url($input);
$ip = gethostbyname($parse['host']);
if (preg_match("$ValidIp", "$ip")) {
echo "$ip";
} else {
echo "none";
}