|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2019-07-15 11:03 UTC] daniil at daniil dot it
 Description:
------------
When resolving MX records with the dns_get_record function, getting the raw record data isn't supported for some reason.
Test script:
---------------
<?php
echo ("Normal:\n");
var_dump(dns_get_record('daniil.it', DNS_MX, $auth, $add, false));
var_dump($auth, $add);
echo ("\nRaw:\n");
var_dump(dns_get_record('daniil.it', DNS_MX, $auth, $add, true));
var_dump($auth, $add)
Expected result:
----------------
Normal:
array(1) {
  [0]=>
  array(6) {
    ["host"]=>
    string(9) "daniil.it"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(300)
    ["type"]=>
    string(2) "MX"
    ["pri"]=>
    int(10)
    ["target"]=>
    string(13) "mx.yandex.net"
  }
}
NULL
NULL
Raw:
array(1) {
  [0]=>
  array(6) {
    ["host"]=>
    string(9) "daniil.it"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(300)
    ["type"]=>
    int(16384)
    ["data"]=>
    string(X) "binary data representing MX record"
  }
}
NULL
NUL
Actual result:
--------------
Normal:
array(1) {
  [0]=>
  array(6) {
    ["host"]=>
    string(9) "daniil.it"
    ["class"]=>
    string(2) "IN"
    ["ttl"]=>
    int(300)
    ["type"]=>
    string(2) "MX"
    ["pri"]=>
    int(10)
    ["target"]=>
    string(13) "mx.yandex.net"
  }
}
NULL
NULL
Raw:
array(0) {
}
NULL
NUL
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 03:00:01 2025 UTC | 
This is a case of bad docs... if raw mode is used, then you need to pass the raw DNS type ID (15 for MX). The DNS_* constants cannot be used (they are a bitmask, not a single type). The correct code is: echo ("\nRaw:\n"); var_dump(dns_get_record('daniil.it', 15, $auth, $add, true)); var_dump($auth, $add);