PHP | checkdnsrr() Function Last Updated : 05 Dec, 2022 Comments Improve Suggest changes Like Article Like Report The checkdnsrr() function is an inbuilt function in PHP that is used to check the DNS records corresponding to the hostname or IP address. This function can be used to verify whether a domain name exists or not. Syntax: bool checkdnsrr( string $host, string $type ) Parameters: This function accepts two parameters as mentioned above and described below: $host: It is required parameter. It specifies the host name or IP address which to be checked.$type: It is optional parameter. It specifies the type of DNS record to be checked. Its possible values are: A, AAAA, A6, ANY, CNAME, MX (default), NAPTR, NS, PTR, SOA, SRV, TXT. Return Value: This function returns TRUE if records found, otherwise returns FALSE. Note: This function is available for PHP 4.0.0 and newer version.On Windows platforms this function is available from PHP 5.3.0. Below programs illustrate the checkdnsrr() function in PHP: Program 1: PHP <?php $domain = "geeksforgeeks.org"; if(checkdnsrr($domain, "MX")) { echo "Record exists."; } else { echo "Record not found or error occurred."; } ?> Output: Record exists. Program 2: PHP <?php $domain = "geeksforgeeks.org"; $arr = array( "A", "MX", "NS", "SOA", "PTR", "CNAME", "AAAA", "A6", "SRV", "NAPTR", "TXT", "ANY" ); foreach( $arr as $element) { echo $element . ":"; if(checkdnsrr($domain, $element)) { echo "found <br>"; } else { echo "not found <br>"; } } ?> Output: A:found MX:found NS:found SOA:found PTR:found CNAME:found AAAA:found A6:found SRV:found NAPTR:found TXT:found ANY:found Reference: https://www.php.net/manual/en/function.checkdnsrr.php Comment More infoAdvertise with us Next Article PHP | checkdnsrr() Function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | dns_check_record() Function The dns_check_record() function is an inbuilt function in PHP which is used to check the DNS records corresponding to the hostname or IP address. This function can be used to verify whether a domain name exists or not. Note: This function is an alias of the checkdnsrr() function. Syntax:Â Â bool dns_ 2 min read PHP | is_dir( ) Function The is_dir() function in PHP used to check whether the specified file is a directory or not. The name of the file is sent as a parameter to the is_dir() function and it returns True if the file is a directory else it returns False. Syntax: is_dir($file) Parameters Used: The is_dir() function in PHP 1 min read PHP | dns_get_mx() Function The dns_get_mx() function is an inbuilt function in PHP which returns MX records for the specified internet host name. This function is an alias of the getmxrr() function. Syntax: bool dns_get_mx( $host, $mxhosts, $weight ); Parameter: This function accepts three parameters as mentioned above and de 1 min read PHP | exit( ) Function The exit() function in PHP is an inbuilt function which is used to output a message and terminate the current script. The exit() function only terminates the execution of the script. The shutdown functions and object destructors will always be executed even if exit() function is called. The message 2 min read PHP | fnmatch( ) Function The fnmatch() function in PHP used to match a filename or string against a specified pattern. The pattern and the filename to be checked are sent as parameters to the fnmatch() function and it returns True if a match is found and False on failure. fnmatch() function is now available for Windows plat 2 min read Like