dns_lookup()


按指定域名传送DNS查询返还应答

Description

string dns_lookup(string $name, int $type)

Parameters

Return Value

成功时IP地址,失败时输入的域名的名称 a

Example

<?php
include "/lib/sn_dns.php";
dns_setup(0);   // UDP 0
$host_name = "www.phpoc.com";
$host_addr = dns_lookup($host_name, RR_A); // sending query for www.phpoc.com
if($host_addr == $host_name)
  echo "$host_name: Not Found\r\n";        // on fail
else
  echo "$host_name: $host_addr\r\n";       // on sucess, output host's IP address
?>

See also