1. Go to this page and download the library: Download remotelyliving/php-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/ */
remotelyliving / php-dns example snippets
$resolver = new Resolvers\GoogleDNS();
// can query via convenience methods
$records = $resolver->getARecords('google.com'); // returns a collection of DNS A Records
// can also query by any RecordType.
$moreRecords = $resolver->getRecords($hostname, DNSRecordType::TYPE_AAAA);
// can query to see if any resolvers find a record or type.
$resolver->hasRecordType($hostname, $type) // true | false
$resolver->hasRecord($record) // true | false
// This becomes very powerful when used with the Chain Resolver
$chainResolver = new Chain($cloudFlareResolver, $googleDNSResolver, $localDNSResolver);
// returns the first non empty result set
$chainResolver->withFirstResults()->getARecords('facebook.com');
// returns the first non empty result set from a randomly selected resolver
$chainResolver->randomly()->getARecords('facebook.com');
// returns only common results between resolvers
$chainResolver->withConsensusResults()->getARecords('facebook.com');
// returns all collective responses with duplicates filtered out
$chainResolver->withAllResults()->getARecords('facebook.com');
$cachedResolver = new Resolvers\Cached($cache, $resolverOfChoice);
$cachedResolver->getRecords('facebook.com'); // get from cache if possible or falls back to the wrapped resolver and caches the returned records