Skip to main content

Domain Whois Lookup with PHP

Whois is a way to check ownership of a domain name. We can know ownership information like owner name, address, etc. from whois record.

There are many ways are available to check whois recode. In Linux system you can run whois command to check whois recode. We can also build our won application to fetch whois recode. In this post I will show you how can can get whois recode with pure php code.

Download Source

The Whois Class

/**
* Domain Whois with PHP & CURL
* @author Resalat Haque
* @link http://www.w3bees.com
*/
class Whois
{
  /**
   * whois servers list
   * 
   * @var array
   */
  var $whois_servers = array(
    'com' => 'whois.crsnic.net',
    'net' => 'whois.verisign-grs.com',
    'org' => 'whois.pir.org',
    'info' => 'whois.afilias.info',
    'biz' => 'whois.neulevel.biz',
    'us' => 'whois.nic.us',
    'uk' => 'whois.nic.uk',
    'ca' => 'whois.cira.ca',
    'tel' => 'whois.nic.tel',
    'ie' => 'whois.iedr.ie',
    'it' => 'whois.nic.it',
    'li' => 'whois.nic.li',
    'no' => 'whois.norid.no',
    'cc' => 'whois.nic.cc',
    'eu' => 'whois.eu',
    'nu' => 'whois.nic.nu',
    'au' => 'whois.aunic.net',
    'de' => 'whois.denic.de',
    'ws' => 'whois.worldsite.ws',
    'sc' => 'whois2.afilias-grs.net',
    'mobi' => 'whois.dotmobiregistry.net',
    'pro' => 'whois.registrypro.pro',
    'edu' => 'whois.educause.net',
    'tv' => 'whois.nic.tv',
    'travel' => 'whois.nic.travel',
    'name' => 'whois.nic.name',
    'in' => 'whois.inregistry.net',
    'me' => 'whois.nic.me',
    'at' => 'whois.nic.at',
    'be' => 'whois.dns.be',
    'cn' => 'whois.cnnic.cn',
    'asia' => 'whois.nic.asia',
    'ru' => 'whois.ripn.ru',
    'ro' => 'whois.rotld.ro',
    'aero' => 'whois.aero',
    'fr' => 'whois.nic.fr',
    'se' => 'whois.iis.se',
    'nl' => 'whois.sidn.nl',
    'nz' => 'whois.srs.net.nz',
    'mx' => 'whois.nic.mx',
    'tw' => 'whois.apnic.net',
    'ch' => 'whois.nic.ch',
    'hk' => 'whois.hknic.net.hk',
    'ac' => 'whois.nic.ac',
    'ae' => 'whois.nic.ae',
    'af' => 'whois.nic.af',
    'ag' => 'whois.nic.ag',
    'al' => 'whois.ripe.net',
    'am' => 'whois.amnic.net',
    'as' => 'whois.nic.as',
    'az' => 'whois.ripe.net',
    'ba' => 'whois.ripe.net',
    'bg' => 'whois.register.bg',
    'bi' => 'whois.nic.bi',
    'bj' => 'www.nic.bj',
    'br' => 'whois.nic.br',
    'bt' => 'whois.netnames.net',
    'by' => 'whois.ripe.net',
    'bz' => 'whois.belizenic.bz',
    'cd' => 'whois.nic.cd',
    'ck' => 'whois.nic.ck',
    'cl' => 'nic.cl',
    'coop' => 'whois.nic.coop',
    'cx' => 'whois.nic.cx',
    'cy' => 'whois.ripe.net',
    'cz' => 'whois.nic.cz',
    'dk' => 'whois.dk-hostmaster.dk',
    'dm' => 'whois.nic.cx',
    'dz' => 'whois.ripe.net',
    'ee' => 'whois.eenet.ee',
    'eg' => 'whois.ripe.net',
    'es' => 'whois.ripe.net',
    'fi' => 'whois.ficora.fi',
    'fo' => 'whois.ripe.net',
    'gb' => 'whois.ripe.net',
    'ge' => 'whois.ripe.net',
    'gl' => 'whois.ripe.net',
    'gm' => 'whois.ripe.net',
    'gov' => 'whois.nic.gov',
    'gr' => 'whois.ripe.net',
    'gs' => 'whois.adamsnames.tc',
    'hm' => 'whois.registry.hm',
    'hn' => 'whois2.afilias-grs.net',
    'hr' => 'whois.ripe.net',
    'hu' => 'whois.ripe.net',
    'il' => 'whois.isoc.org.il',
    'int' => 'whois.isi.edu',
    'iq' => 'vrx.net',
    'ir' => 'whois.nic.ir',
    'is' => 'whois.isnic.is',
    'je' => 'whois.je',
    'jp' => 'whois.jprs.jp',
    'kg' => 'whois.domain.kg',
    'kr' => 'whois.nic.or.kr',
    'la' => 'whois2.afilias-grs.net',
    'lt' => 'whois.domreg.lt',
    'lu' => 'whois.restena.lu',
    'lv' => 'whois.nic.lv',
    'ly' => 'whois.lydomains.com',
    'ma' => 'whois.iam.net.ma',
    'mc' => 'whois.ripe.net',
    'md' => 'whois.nic.md',
    'mil' => 'whois.nic.mil',
    'mk' => 'whois.ripe.net',
    'ms' => 'whois.nic.ms',
    'mt' => 'whois.ripe.net',
    'mu' => 'whois.nic.mu',
    'my' => 'whois.mynic.net.my',
    'nf' => 'whois.nic.cx',
    'pl' => 'whois.dns.pl',
    'pr' => 'whois.nic.pr',
    'pt' => 'whois.dns.pt',
    'sa' => 'saudinic.net.sa',
    'sb' => 'whois.nic.net.sb',
    'sg' => 'whois.nic.net.sg',
    'sh' => 'whois.nic.sh',
    'si' => 'whois.arnes.si',
    'sk' => 'whois.sk-nic.sk',
    'sm' => 'whois.ripe.net',
    'st' => 'whois.nic.st',
    'su' => 'whois.ripn.net',
    'tc' => 'whois.adamsnames.tc',
    'tf' => 'whois.nic.tf',
    'th' => 'whois.thnic.net',
    'tj' => 'whois.nic.tj',
    'tk' => 'whois.nic.tk',
    'tl' => 'whois.domains.tl',
    'tm' => 'whois.nic.tm',
    'tn' => 'whois.ripe.net',
    'to' => 'whois.tonic.to',
    'tp' => 'whois.domains.
    tl',
    'tr' => 'whois.nic.tr',
    'ua' => 'whois.ripe.net',
    'uy' => 'nic.uy',
    'uz' => 'whois.cctld.uz',
    'va' => 'whois.ripe.net',
    'vc' => 'whois2.afilias-grs.net',
    've' => 'whois.nic.ve',
    'vg' => 'whois.adamsnames.tc',
    'xxx' => 'whois.nic.xxx',
    'yu' => 'whois.ripe.net'
    );
  
  /**
   * domain
   * @var string
   */
  var $domain;

  /**
   * TLD
   * 
   * @var string
   */
  var $tld;

  /**
   * @param str $url
   * 
   * @return void
   */
  function __construct($domain)
  {
    $this->domain = $domain;
    $this->tld = $this->getTld($this->domain);
  }

  /**
   * get whois recode
   * 
   * @return string
   */
  function get()
  {
    if (array_key_exists($this->tld, $this->whois_servers))
    {
      $server = $this->whois_servers[$this->tld];
      return $this->sendRequest($server, $this->domain);
    }
    else
    {
      return 'Unsupported domain name';
    }
  }

  /**
   * get TLD from domain name
   * 
   * @param string $doamin
   * @return string
   */
  function getTLD($domain)
  {
    $domain = explode('.', $domain);
      $lst = count($domain) - 1;
      return isset($domain[$lst]) ? $domain[$lst] : '';
  }

  /**
   * send request to the whois server
   * 
   * @param string $server
   * @param string $domain
   * 
   * @return string
   */
  function sendRequest($server, $doamin)
  {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $server);
    curl_setopt($ch, CURLOPT_PORT, 43);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $doamin . "\r\n");
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
  }
}

Usage

$whois = new Whois('w3bees.com');
echo '<pre>'. $whois->get() .'</pre>';

Comments

  1. Replies
    1. dongtam
      mu moi ra hom nay
      tim phong tro
      http://nhatroso.com/
      nhạc sàn
      tổng đài tư vấn luật
      văn phòng luật hà nội
      tổng đài tư vấn luật
      thành lập công ty trọn gói
      http://we-cooking.com/
      chém gió
      trung tâm tiếng anhsắc mặt của hắn liền biến đổi lớn.

      Một mảng hắc mang tràn ngập giống như là biển gầm đánh về phía Hỏa Lão, đồng thời thân hình của Địa Ma Lão Nhân một lần nữa lui về phía dưới.

      Địa Ma Lão Nhân hiểu rõ trong lòng, mình mặc dù có thực lực bát tinh Đấu Tôn đỉnh phong nhưng so với cửu tinh Đấu Tôn thì vẫn còn kém xa, hai thực lực cách biệt một trời một vực.

      - Xoẹt.

      Một mảng hồng mang nóng bỏng hiện lên, Nhạc Thành đã cảm nhận thấy Hỏa Lão đã khôi phục thực lực tới cửu tinh Đấu Tôn, ngọn lửa trên người cũng ngày càng trở nên cường hãn.

      - Xoẹt xoẹt.

      Hai luồng lực lượng dây dưa một chỗ, Hỏa Lão ngưng tụ hỏa diễm cho thấy uy lực mạnh hơn rất nhi ào, hú.

      Cùng với việc Hỏa Lão và Địa Ma Lão Nhân triển khai công kích, Cự Viên Tộc ma thú cũng công kích bảy con ma thú của Hắc Ám Thần Điện.

      Kim Cương tộc trưởng chọn hai con ma thú cấp tám trung kỳ, với thực lực của Kim Cương tộc trưởng đối với mấy con ma thú này không hề có chút vấn đề gì.

      Delete
  2. Thanks for your information. There are lot of ways available to check whois history. I have checked whois information from this site Whoisxy.com

    ReplyDelete
  3. thank you very much for this script
    is it possible to connect to whois server through a proxy ??

    ReplyDelete
  4. Is there any further reading you would recommend on this?

    Anne Cole

    who is visiting my website

    ReplyDelete
    Replies
    1. Nicely explained. Here you described the well written article from your in-depth knowledge. Truly impressive and nice information

      Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

      Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

      Delete
  5. Replies
    1. I have read your blog its very attractive and impressive. I like it your blog.

      ES6 Online Training JavaScript Training Courses JavaScript Training Courses | Angular 4 Online Training Angular 4 Online Training

      Delete
  6. Hi. It is not working for DE-Domains?

    ReplyDelete
  7. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post. Your articles really impressed for me,because of all information so nice.

    SAP training in Chennai

    ReplyDelete
  8. I love your blog..Have a great day
    http://crackslink.com/kasper-antivirus-2016-crack/

    ReplyDelete
  9. doesnt work for the server whois.na-nic.com.na, i added is to the array

    ReplyDelete
  10. doesnt work for the server whois.na-nic.com.na, i added is to the array

    ReplyDelete
  11. Great post.
    It really helped me to learn something new. So thanks.
    Linux training in Bangalore

    ReplyDelete
  12. This is the precise weblog for anybody who needs to seek information about this topic.You positively put a brand new spin on a subject that has been written about for years. Nice stuff simply nice!

    ReplyDelete
  13. There are no words to encourage about your post. It’s not only helpful to me. All of the small business can gain lots benefits by read your post.
    android training in Bangalore | Big data analytics training in Bangalore

    ReplyDelete
  14. Yeah. I am very interesting to start my website domain using PHP. Because, today lots of small business is working based on PHP. Moreover, your source code will give good support to me.

    PHP Training in Bangalore

    ReplyDelete
  15. Very informative post
    if any one learn php Programming join our Best php training Institute in Delhi Thank You Keep Posting

    ReplyDelete
  16. Really useful blog. Thank you for the post

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. what is .co indian Whois server

    ReplyDelete
  19. Thanks for your useful information. I learned new things from this blog. PHP training in bangalore

    ReplyDelete
  20. Thanks for sharing this useful information. Nice post it will help to improve technical knowledge. Spring training in Bangalore

    ReplyDelete
  21. Wow..great job. keep on sharing like this useful blogs.best angularjs training in Bangalore

    ReplyDelete
  22. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted "Oracle Training in Bangalore".

    ReplyDelete
  23. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site. rprogramming training in bangalore

    ReplyDelete
  24. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    java-training in chennai

    ReplyDelete
  25. Thanks for your informative article. Java is most popular programming language used for creating rich enterprise, desktop and web applications. Keep on updating your blog with such informative post.
    JAVA Training in Chennai|JAVA Course in Chennai|Best JAVA Training in Chennai

    ReplyDelete
  26. Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.
    Regards,

    Data Science Course in Chennai

    ReplyDelete
  27. Nice piece of information on HTML5. With the expansion of smartphones and other portable gadgets, the demand for responsive website design that go comfy on all devices keeps on increasing. This leads to invention and expansion of HTM5 web technology.PHP Training in Chennai

    ReplyDelete
  28. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    python-training in chennai

    ReplyDelete
  29. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

    AWS TRAINING IN BANGALORE

    ReplyDelete
  30. It has been simply incredibly generous with you to provide openly
    what exactly many individuals would’ve marketed for an eBook to end
    up making some cash for their end, primarily given that you could
    have tried it in the event you wanted.


    aws training in chennai



    aws training in bangalore

    ReplyDelete
  31. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.digital marketing training in chennai

    ReplyDelete
  32. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area. hadoop training in bangalore

    ReplyDelete
  33. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    python training in bangalore

    ReplyDelete
  34. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    data science training in chennai

    ReplyDelete
  35. There are numerous websites that use exact same code and give us the details upfront.

    Great working and we can use the same in other server side technologies like Best Node JS training in Chennai

    Thanks for the insights. :)

    ReplyDelete
  36. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    oracle training in Bangalore

    ReplyDelete
  37. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    oracle training in Bangalore

    ReplyDelete
  38. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.
    java training in chennai

    ReplyDelete
  39. Very nice information its very useful to read your blog. We provide best austeretech.com/digital-transformation Digital Transformation Services

    ReplyDelete
  40. Very good informative article. Thanks for sharing such nice article, keep on up dating such good articles.

    NO.1 APP DEVELOPMENT SERVICES | MASSIL TECHNOLOGIES

    ReplyDelete
  41. REALLY VERY EXCELLENT INFORMATION. I AM VERY GLAD TO SEE YOUR BLOG FOR THIS INFORMATION. THANKS FOR SHARING. KEEP UPDATING.

    NO.1 IOT Services | INTERNET OF THINGS | Best IOT Services |

    ReplyDelete
  42. HiAdmin,
    I go through your blog and it’s really awesome. Keep updating your site with such useful post. Also include Rss feed of your blog

    performance testing training in chennai | Best QTP Training Center in Chennai

    ReplyDelete
  43. Great information about PHP, very helpful information. Thanks for shring.
    Best Mobility Services | Austere Technologies

    ReplyDelete
  44. Thanks for the complete guidance on domain whois lookup. Hope your article has reserve a unique place among blog readers.
    PHP Training
    PHP Institutes in Chennai

    ReplyDelete
  45. Excellent information with a great explanation. Thanks for sharing, keep updating.

    NO.1 CLOUD SERVICES | Oracle Cloud PAAS | MASSIL TECHNOLOGIES

    ReplyDelete

  46. Post shows good and much informative, thanks for sharing and

    your valuable time.To keep share this kind of useful things.Advance JAVA / J2EE Training courses in

    Chennai
    | JAVA / J2EE Training courses in

    Kancheepuram

    ReplyDelete
  47. Nice post. I learned some new information. Thanks for sharing.

    Guest posting sites
    Education

    ReplyDelete
  48. Nice blog…. with lovely information. Really very useful article for us thanks for sharing such a wonderful blog. Keep updating…..
    No.1 Ethical Hacking Training institute in Chennai | No.1 Ethical Hacking Training institute in Kanchipuram

    ReplyDelete
  49. Thanks for the nice information and also it's very inspirational and Thanks for the detailed explanation. Really useful. Keep sharing more. Regards. Click Here for Commerce College in Hyderabad

    ReplyDelete
  50. Nice and good info. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating...
    No.1 CCNA certification Training institute in Chennai|
    No.1 CCNA certification Training institute in Velachery|
    No.1 CCNA certification Training institute in Kanchipuram|

    ReplyDelete
  51. Thanks for sharing with us. You really provide useful information and it made my day. Appreciate your effort. Keep sharing.

    Salesforce Developer Training in Bangalore | Salesforce Course in Bangalore

    ReplyDelete
  52. Wow...What an excellent informative blog, really helpful. Thank you. Best Oracle DBA Course Training| orskl

    ReplyDelete
  53. Excellent information with unique content and it is very useful to know about the information based on blogs...
    Best Summer courses Training Institute in Kanchipuram|

    ReplyDelete
  54. I have read your blog it’s very attractive and impressive. I like it your blog.
    Summer Camp in Kanchipuram

    ReplyDelete
  55. Such a cute blog. Thank you for blogging. Keep adding more blogs and Very nicely presented.
    Best Summer Courses training in Kanchipuram|

    ReplyDelete
  56. I have read blog, its very attractive and impressive.thanks for sharing,,Best vacation classes for Students in Kanchipuram|

    ReplyDelete
  57. Nice post... Really you are done a wonderful job. Thanks for sharing such wonderful information with us. Please keep on updating...
    Best Summer Classes in Kanchipuram|

    ReplyDelete
  58. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    Data Science Training in Chennai | Data Science Course in Chennai
    Python Course in Chennai | Python Training Course Institutes in Chennai
    RPA Training in Chennai | RPA Training in Chennai
    Digital Marketing Course in Chennai | Best Digital Marketing Training in Chennai

    ReplyDelete
  59. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
    Best Vacation Courses in Kanchipuram|

    ReplyDelete
  60. Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it
    Vacation Courses in Chennai | Vacation Courses in Keelkattalai

    ReplyDelete
  61. I have read your blog. It’s very informative and useful blog. You have done really great job. Keep update your blog. Thanks..
    Best Summer Courses Training Institute in Kanchipuram

    ReplyDelete
  62. Thanks for sharing this niche useful informative post to our knowledge.
    Vacation Courses in Chennai | Vacation Courses in Pallikaranai

    ReplyDelete
  63. Thank you so much for sharing this worth able content with us. It's Very Useful content.
    Best Vacation Courses in Kanchipuram

    ReplyDelete
  64. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge.
    Vacation Courses in Chennai | Vacation Courses in Perungudi

    ReplyDelete
  65. I have read your blog its very attractive and impressive. I like it your blog.
    Summer courses in Chennai | Summer courses in Nanganallur

    ReplyDelete
  66. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
    Best Vacation Classes in Kanchipuram

    ReplyDelete
  67. Thanks for posting this information it was really good and useful for me. Got many innovative ideas.AWS Training in Chennai | AWS Training in Taramani

    ReplyDelete
  68. I am reading your blog regularly, what a post very interesting and great content. Thank you for your post!!!
    Best Selenium Training Institute in Kanchipuram

    ReplyDelete
  69. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Best Python Training Institute in Kanchipuram

    ReplyDelete
  70. Excellent information with unique content and it is very useful to know about the information based on blogs...
    Best Android and iOS Training Institute in Chennai | Best Android and iOS Training Institute in Madipakkam

    ReplyDelete
  71. Thanks for Sharing this great article..Its really nice and useful for us… keep sharing..CEH Training In Hyderabad

    ReplyDelete

  72. Thanks for posting this information it was really good and useful for me. Got many innovative ideas.
    Android Training Course in Chennai | Android Training Course in Adyar

    ReplyDelete

Post a Comment

Popular posts from this blog

Multiple File Upload with Progress Bar using PHP & jQuery

Some days age I have created a post that deals with How we can upload file with progress bar using php and jQuery. Some of my readers asked me how we can upload multiple files with progress bar. In this post I am going to show you how we can upload multiple files with progress bar.We can upload multiple files with progress bar exactly same way as I shown previous. But we need to do some modification with our file upload form and our php script to handle multiple files.

Force File Download with PHP

If you want to control or track your downloadable contents then a force file downloader script can give you more option. Especially if you want make images or other stemming contents like music file (mp3, wav, ogg), video files (flv, mp4, ogg, 3gpp), css, JavaScripts or even a php file downloadable then you must need to use a force file downloader script.
In this post I am going to share a simple but useful force file downloader script.

File Upload with Progress Bar using jQuery and PHP

In this post you will learn how to create a AJAX file uploading system with progress bar using jQuery and PHP. For this purpose we will going to use jQuery Form Plugin. It is a easy to use and powerful jQuery AJAX form submitting plugin. It supports XMLHttpRequest Level 2 and iframe file transportation. That's why it will work for both old and new browsers.