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: Fri, 09 Oct 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.