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

  • SEARCH
  • Home
  • 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 7948863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:50:46+00:00 2026-06-04T01:50:46+00:00

I was trying out checkdnsrr() function in PHP to test whether a given hostname

  • 0

I was trying out checkdnsrr() function in PHP to test whether a given hostname is valid or not.

Below is the PHP code:

$url = "this_is_a_wrong_url.com";
if (checkdnsrr($url, 'A')) 
{
    echo "Domain exists.";
}
else
{
     echo "Domain doesnot exists.";
}

But it is returning true even for invalid url’s.

What am I doing wrong? I am using PHP 5.3.5

EDIT: This code is working fine on Linux machines with same PHP version. Its giving invalid result only on Windows 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-04T01:50:48+00:00Added an answer on June 4, 2026 at 1:50 am

    Some ISPs will redirect invalid domains to their own search servers. TimeWarner/RoadRunner is one such ISP. Your code works fine, but you might want to check to make sure they don’t resolve to your ISP’s search servers. Use gethostbyname first to check an invalid domain, then use that to check against.

    if (checkdnsrr($url, 'A') && gethostbyname($url) != '204.232.137.207' && gethostbyname($url) !='66.152.109.110')
    

    Or better is

    if(checkdnsrr($url,'A') && !in_array(gethostbyname($url),gethostbynamel('this_is_a_wrong_url.com')))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying out the examples found on pleac.sf.net , I'm not able to get an
I'm trying out my first recursive function (at least I think I am!) and
I've been trying out some of the view code from Erica Sadun's book The
I am trying out DevExpress Xtrareports, but have asimple problem that I am not
I have been trying out EF 4.1 ( code first ) with MVC 3.
I'm trying out very simple search popup on the JqGrid. Please see the code
I trying out some problems in Google's Code Jam. For the question Store Credit
I'm currently trying out a few of the new C++0x features, namely std::function and
Trying out PDO for the first time. $dbh = new PDO(mysql:host=$hostname;dbname=animals, $username, $password); $stmt
Trying out some things with php and html, I'm having issues trying to get

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.