PHP code example of antedebaas / dns-parser

1. Go to this page and download the library: Download antedebaas/dns-parser 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/ */

    

antedebaas / dns-parser example snippets


use Ante\DnsParser\Dns;

$dns = new Dns();

$dns->getRecords('spatie.be'); // returns all available dns records

$dns->getRecords('spatie.be', 'A'); // returns only A records

$records = $dns->getRecords('spatie.be')

$hostNameOfFirstRecord = $records[0]->host();

use Ante\DnsParser\Dns;

$dns = new Dns();

$dns->getRecords('spatie.be'); // returns all available dns records

$dns->getRecords('spatie.be', 'A'); // returns only A records
$dns->getRecords('spatie.be', ['A', 'CNAME']); // returns both A and CNAME records
$dns->getRecords('spatie.be', DNS_MX); // returns only MX records
$dns->getRecords('spatie.be', DNS_A | DNS_AAAA); // returns both A and AAAA records

$ARecord = $dns->getRecords('spatie.be', 'A')[0];

(string)$ARecord // returns `spatie.be.              900     IN      A       138.197.187.74`

use Ante\DnsParser\Dns;

(new Dns)
    ->useNameserver('ns1.openminds.be') // use ns1.openminds.be
    ->getRecords('spatie.be');

use \Ante\DnsParser\Support\Factory();

// returns instance of \Ante\DnsParser\Records\CNAME
(new Factory())->guess('www.spatie.be.       300     IN      CNAME   spatie.be.');

$results = $this->dns
    ->useHandlers([new YourCustomHandler()])
    ->getRecords('spatie.be');