Net_DNS_Resolver::rawQuery() – Queries a nameserver and returns a response



Net_DNS_Packet Net_DNS_Resolver::rawQuery ( string $hostname , string $type = 'A' , string $class = 'IN' )


  • hostname - The name to lookup (eg.

  • type - The record type to query

  • class - The zone class to query

The Net_DNS_Resolver::rawQuery() function performs a DNS query similar to the Net_DNS_Resolver::query() function; however, rawQuery() will return any response from the nameserver. This is useful when the response packet may or may not contain any resource records in the "ANSWER" section.

rawQuery() uses the same resolver configuration used by Net_DNS_Resolver::query().

For a description of the returned RR data object, see Net_DNS_RR.


Using Net_DNS_Resolver::rawQuery()

require_once 'Net/DNS.php';

$resolver = new Net_DNS_Resolver();
$response $resolver->rawQuery('');
if (
$response) {
  if (
count($response->answer)) {
    foreach (
$response->answer as $rr) {

Output:            129808  IN      A


This function can not be called statically.

Queries a nameserver and returns a response (Previous) Performs a zone transfer from a nameserver (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.