Change language

PHP dns_get_record () function

Syntax:
dns_get_record ($host, $type, $authoritative, $additional, $raw);
Parameter:This function takes five parameters as above and described below:
  • $host : This is required parameter. It specifies the name of the host whose DNS resource records are to be found.
  • $type : This is an optional parameter. Specifies the type of DNS record to look up. Possible Values ​​
    • DNS_A
    • DNS_CNAME
    • DNS_HINFO
    • DNS_CAA
    • DNS_MX
    • DNS_NS
    • DNS_PTR
    • DNS_SOA
    • DNS_TXT
    • DNS_AAAA
    • DNS_SRV
    • DNS_NAPTR
    • DNS_A6
    • DNS_ALL
    • DNS_ANY (default)
  • $authoritative:this is an optional parameter. It is passed by reference and populated with resource records for authoritative name servers, if installed.
  • $Additional:This parameter is optional. It is passed by reference and will be populated with any additional entries if installed.
  • $raw:This is an optional parameter. Boolean If set to TRUE, instead of looping type-to-type, it queries only the requested type before retrieving information. FALSE - this is the default.
Returned value:
  • Returns an array of associative arrays, FALSE on error. Each array contains the following keys (at least):
    • host:hostname
    • class:this function only returns internet records -class, so it always returns IN
    • type:post type
    • ttl:"Time To Live" remaining for this records (calculated as original ttl minus
      elapsed time since server request)
Note.This feature is available for PHP 5.0.0 and later.Example 1: print_r (dns_get_record ( "engineerforengineer.org" , DNS_MX)); ?> Output: Array ([0] = > Array ([host] = > engineerforengineer.org [class] = > IN [ttl] = > 299 [type] = > MX [pri] = > 1 [target] = > aspmx.l.google.com) [1] = > Array ([host] = > engineerforengineer.org [class] = > IN [ttl] = > 299 [ type] = > MX [pri] = > 10 [target] = > alt3.aspmx.l.google.com) [2] = > Array ([host] = > engineerforengineer.org [class] = > IN [ttl] = > 299 [type] = > MX [pri] = > 10 [target] = > alt4.aspmx.l.google.com) [3] = > Array ([host ] = > engineerforengineer.org [class] = > IN [ttl] = > 299 [type] = > MX [pri] = > 5 [target] = > alt1.aspmx.l.google.com ) [4] = > Array ([host] = > engineerforengineer.org [class] = > IN [ttl] = > 299 [type] = > MX [pri] = > 5 [target] = > alt2.aspmx.l.google.com)) Example 2:systematic inference $res = dns_get_record ( "engineerforengineer.org" , DNS_MX); foreach ( $res as $ar ) { foreach ( $ar as $key = > $val ) { echo $key . ":" . $val . "
"
; } echo "
"
; }  
?>
Output: Example 3:all possible values ​​of type $ $domain = "engineerforengineer.org" ; single_type_dns_get_record ( $domain , DNS_A) ; single_type_dns_get_record ( $domain , DNS_CNAME) ; single_type_dns_get_record ( $domain , DNS_HINFO) ; single_type_dns_get_record ( $domain , DNS_CAA) ; single_type_dns_get_record ( $domain , DNS_MX) ; single_type_dns_get_record ( $domain , DNS_NS) ; single_type_dns_get_record ( $domain , DNS_PTR) ; single_type_dns_get_record ( $domain , DNS_SOA) ; single_type_dns_get_record ( $domain , DNS_TXT) ; single_type_dns_get_record ( $domain , DNS_AAAA) ; single_type_dns_get_record ( $domain , DNS_SRV) ; single_type_dns_get_record ( $domain , DNS_NAPTR) ; single_type_dns_get_record ( $domain , DNS_A6) ; single_type_dns_get_record ( $domain , DNS_ALL) ; single_type_dns_get_record ( $domain , DNS_ANY) ; function single_type_dns_get_record ( $domain , $type ) { echo "-------------
"
. $type . "
-------------
"
; $res = dns_get_record ( $domain , $type ); foreach ( $res as $ar ) { foreach ( $ar as $key = > $val ) { echo $key . ": " . $val . "
"
; } echo "
"
; } }  
?>
Output: Link : https://www.php.net/manual /en/function.dns-get-record.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method