Without using PECL or system() type functions, is there a way to look up DNS records using PHP?

StackOverflow https://stackoverflow.com/questions/2907574

  •  04-10-2019
  •  | 
  •  

문제

I'm working on creating a new type of email protocol, and in order to do that I had to set up an SRV DNS record for my domain.

In promoting this protocol, I'll need to be able to discover if a given host uses my system (and if not fall back to an older protocol).

So, is there a way to pull a DNS record (such as SRV) using PHP without using a PECL extension or running it through the linux command line (I already know I can ob_start() and system("host -t SRV hostname") but I'm looking for a better way, if it exists.)

도움이 되었습니까?

해결책

Use dns_get_record

array dns_get_record  (  string $hostname  [,  int $type = DNS_ANY  [,  array &$authns  [,  array &$addtl  ]]] )

Fetch DNS Resource Records associated with the given hostname.

다른 팁

Have you considered PEAR::Net_DNS?
http://pear.php.net/package/Net_DNS

As far as I can tell it uses socket connections (tcp/udp) and decodes the resolver data itself. The available methods look pretty extensive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top