getdns Functions
PHP Manual


(PECL getdns >= 0.10.0)

php_getdns_general_syncSynchronously perform a DNS query for records of a specified type.


int php_getdns_general_sync ( int $context , string $name , int $reqType , int $extensions , int &$response )

This function provides an entry point into the getdns API library to synchronously retrieve any valid responses to a query from the DNS; note that other namespaces in the context are not used. Most typical use cases for applications are probably satisifed via calls to php_getdns_address_sync(), which would replace getaddrinfo().



The previously created DNS context that is to be used with this request.


The ASCII-based domain name to be looked up as a string. This can also be an IPv4 or IPv6 address for request types that take addresses instead of domain names, such as PTR. The values here follow the rules in section 2.1 of » RFC 4343 to allow non-ASCII octets and special characters in labels.


The RRtype for the query; the RRtype numbers are listed in the IANA registry. For example, to get the NS records reqType would be 2. This extension has defined constants for most of the RRtypes by name; the definition names all start with "GETDNS_RRTYPE_". For example, to get the NS records you can also set the reqType to GETDNS_RRTYPE_NS.


The extensions dictionary for this request; NULL or 0 (zero) if no extensions.


The dictionary to receive the response. The dictionary always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). Note that this argument is passed by reference and any existing value will be overwritten. The response must be freed using php_getdns_dict_destroy().

Return Values

This function returns an integer response code. GETDNS_RETURN_GOOD indicates successful completion.

getdns Functions
PHP Manual