PHP code example of sirmonti / doh

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

    

sirmonti / doh example snippets


$ipaddresses=DOHGG::dns('www.google.com','A');

$ipaddresses=DOHCF::dns('www.google.com','A');

$resp = DOHCF::dns('www.google.com','A'); // Query cloudflare with a single response
echo "\nResponse A query:\n";
print_r($resp);
printf("DNS response status code: %d\n",DOHCF::getStatus());

$resp = DOHGG:dns('google.com','TXT'); // Query with a multiple response
echo "\nResponse TXT query:\n";
print_r($resp);
printf("DNS response status code: %d\n",DOHGG::getStatus());

$resp = DOHCF::dns('nonexistentdomain.test','TXT'); // Query with an invalid response
echo "\nResponse TXT query:\n";
print_r($resp);
printf("DNS response status code: %d\n",DOHCF::getStatus());