checkdnsrr

(PHP 4, PHP 5)

checkdnsrrПроверяет записи DNS, соответствующие переданному имени узла интернета или IP-адресу

Описание

bool checkdnsrr ( string $host [, string $type = "MX" ] )

Ищет записи DNS типа type, соответствующие host.

Список параметров

host

Параметр host может быть IP-адресом в виде четырех десятичных чисел, разделенных точками, или именем узла.

type

Параметр type может быть одним из: A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY.

Возвращаемые значения

Возвращает TRUE, если были найдены записи; возвращает FALSE, если записей не было найдено или произошла ошибка.

Список изменений

Версия Описание
5.3.0 Функция стала доступна на платформе Windows.
5.2.4 Добавлено значение TXT параметра type.
5.0.0 Добавлено значение AAAA параметра type.

Примечания

Замечание:

Для совместимости с более ранними версиями PHP под Windows, где не было реализации этой функции, используйте класс » PEAR » Net_DNS.

Смотрите также

  • dns_get_record() - Получение DNS свойств и характеристик хоста
  • getmxrr() - Получает запись MX, соответствующую переданному доменному имени узла
  • gethostbyaddr() - Получает доменное имя узла, соответствующее переданному IP-адресу
  • gethostbyname() - Получает адрес IPv4, соответствующий переданному имени узла интернета
  • gethostbynamel() - Возвращает список адресов IPv4, соответствующих переданному доменному имени узла
  • страница руководства named(8)

Коментарии

Автор:
This is a little code example that will validate an email address in two ways:
- first the general syntax of the string is checked with a regular expression
- then the domain substring (after the '@') is checked using the 'checkdnsrr' function

<?php

function validate_email($email){

   
$exp "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";

   if(
eregi($exp,$email)){

      if(
checkdnsrr(array_pop(explode("@",$email)),"MX")){
        return 
true;
      }else{
        return 
false;
      }

   }else{

      return 
false;

   }   
}

?>
2004-12-13 21:53:47
http://php5.kiev.ua/manual/ru/function.checkdnsrr.html
Is not possible validate domains with 'ñ' for my country.

In my country is possible to register domain using 'ñ' character. For example:

ñandu.cl
http://nic.cl/cgi-bin/dom-CL?q=%F1andu

If I use this function to check DNS record, it return false, but the domain already exists:

var_dump(checkdnsrr('ñandu.cl', 'A')); // returns false
2013-07-18 17:57:36
http://php5.kiev.ua/manual/ru/function.checkdnsrr.html
Автор:
criffoh at gmail dot com is right. Before you check domain, you must convert to ascii with idn_to_ascii function:
http://us2.php.net/manual/en/function.idn-to-ascii.php .

var_dump(checkdnsrr('ñandu.cl', 'A')); // returns false
var_dump(checkdnsrr(idn_to_ascii('ñandu.cl'), 'A')); // return true
2013-10-27 13:12:11
http://php5.kiev.ua/manual/ru/function.checkdnsrr.html
Автор:
Important Warning:

You need to add a dot to the end of the host name to make a fully qualified domain name.

To see why, try executing the following pieces of code:

$d1="gmail.con";
$d2="gmail.con.";
$r1=checkdnsrr($d1, "MX"); 
$r2=checkdnsrr($d2, "MX"); 
var_dump($r1);
var_dump($r2);

You will see that without the dot it claims that the domain "gmail.con" is valid.

Note that if you time the "checkdnsrr()" calls you will also see it takes longer without the dot because it treats it as a relative domain and does several tries based on the host name it is running on.

NB: in case you're interested, being treated as a relative domain explains what is happening. If your host is "example.com" the relative domain will eventually resolve to "gmail.con.com." which can be looked up, hence it wrongly claims "gmail.con" exists
2016-09-30 13:02:16
http://php5.kiev.ua/manual/ru/function.checkdnsrr.html
Автор:
$this->_buf - for bulk check cache

function ValidateEmail($email)
    {
        list($user, $domain) = explode('@', $email);

        if (!filter_var($email, FILTER_VALIDATE_EMAIL) !== FALSE)
            return 0;

        if (isset($this->_buf[$domain]))
            return $this->_buf[$domain];

        if (checkdnsrr($domain) === FALSE) {
            $this->_buf[$domain] = 0;
            return 0;
        }
        $this->_buf[$domain] = 1;

        return 1;
    }
2018-07-24 12:04:25
http://php5.kiev.ua/manual/ru/function.checkdnsrr.html
Автор:
I always think you should state the blindingly obvious.
A function that contains checkdnsrr will return false without an internet connection.
So in a production environment you need an active internet connection to return a true result with a valid email address.
2021-07-02 14:39:05
http://php5.kiev.ua/manual/ru/function.checkdnsrr.html

    Поддержать сайт на родительском проекте КГБ