$domain = "example.com"; $ip = gethostbyname($domain); echo "The IP address of $domain is $ip";
$ip = "192.168.0.1"; if(filter_var($ip, FILTER_VALIDATE_IP)) { echo "$ip is a valid IP address"; } else { echo "$ip is not a valid IP address"; }The package library used in this example is also the core PHP library.