Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:48:47+00:00 2026-06-17T16:48:47+00:00

I’m trying get a list of CNAME records using PHP. This method used to

  • 0

I’m trying get a list of CNAME records using PHP.

This method used to work when I was hosting the code on my old Windows 7 machine, but I moved it to an Ubuntu machine (similar AMP stack setup), and it no longer returned CNAME records for the $url. I uploaded the code to a Windows server and still yet, no CNAME records.

$records['cname'] = dns_get_record($url, DNS_CNAME);

Not that I’m claiming the OS has much to do with anything, maybe I had something set up a certain way on my old machine that allowed this to work. It currently returns a simple empty array, where as it used to return a list of CNAME records that matched up with what was in my DNS management service. I’ve read the article here:

Why wouldn't dns_get_record show CNAMEs when I KNOW they exist?

and ended up trying to implement the functionality with Pear’s NetDns2 Library, with the following code. And still, the answer array of the response is empty. Not sure if the problem is the same from get_dns_record to NetDNS2 or if I’m doing something wrong in both cases, but the sites tested surely have CNAME records, including google.com and yahoo.com.

//using Google Name Server
$rslvr = new Net_DNS2_Resolver(array('nameservers' => array('8.8.8.8')));
$records['cname'] = $rslvr->query($url, 'CNAME');

Any help is appreciated, the end goal is to be able to obtain a list of CNAME records like I was on my old machine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:48:47+00:00Added an answer on June 17, 2026 at 4:48 pm

    Works here with PHP 5.4.9.

    The first record (cweiske.de) is no CNAME but directly points to an IP address:

    php > var_dump(dns_get_record('cweiske.de', DNS_CNAME));
    array(0) {
    }
    

    The second is actually a CNAME to the first record:

    php > var_dump(dns_get_record('www.cweiske.de', DNS_CNAME));
    array(1) {
      [0] =>
      array(5) {
        'host' =>
        string(14) "www.cweiske.de"
        'class' =>
        string(2) "IN"
        'ttl' =>
        int(86400)
        'type' =>
        string(5) "CNAME"
        'target' =>
        string(10) "cweiske.de"
      }
    }
    

    dig shows the same:

    $ dig cweiske.de
    cweiske.de.     577 IN  A   83.169.7.198
    
    $ dig www.cweiske.de
    www.cweiske.de.     86397   IN  CNAME   cweiske.de.
    cweiske.de.     597 IN  A   83.169.7.198
    

    To check if it’s your or PHP’s problem, use dig or nslookup to test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.