1. Go to this page and download the library: Download anquanssl/dns library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Let's customize the DNS request handler - TCP
$dnsHandler = (new TCP())
->setPort(53)
->setNameserver('8.8.8.8')
->setTimeout(3) // limit execution to 3 seconds
->setRetries(5); // allows 5 retries if response fails
// Let's initialize the DNS records service
$dnsRecordsService = new DnsRecords($dnsHandler);
// let's get some TXT records from `bluelibraries.com`
$records = $dnsRecordsService->get('bluelibraries.com', RecordTypes::TXT);
// let's display them
print_r($records);
$dnsHandler = (new UDP())
->setPort(53)
->setNameserver('8.8.8.8')
->setTimeout(3) // limit execution to 3 seconds
->setRetries(5); // allows 5 retries if response fails
$dnsHandler = (new DIG())
->setPort(53)
->setNameserver('8.8.8.8')
->setTimeout(3) // limit execution to 3 seconds
->setRetries(5); // allows 5 retries if response fails
// DnsGetRecord allows only Timeout and Retries, but there is no control over timeout
// so the timeout may be much longer than the limit we set!
$dnsHandler = (new DnsGetRecord())
->setTimeout(3) // limit execution to 3 seconds
->setRetries(5); // allows 5 retries if response fails
// TCP is the default DNS handler, so if you are using it then you can skip it
$records = DNS::getRecords('bluelibraries.com', RecordTypes::TXT);
print_r($records);