WHOIS directory lookup in PHP


Posted in: php | Save to del.icio.us | 13 Sep 2008



Net_Whois lets you query a internet name directory service in a easy to use manner. WHOIS is a protocol which is widely used to determine the owner of a domain name, an IP address by querying an official name database. One possible application I can think of is to see if DNS servers are set correctly for various domains I handle regularly.

Installation

Net_Whois being a Pear package we will use the Pear installer as below. I recommend to always use the Pear installer to download packages rather than downloading it manually as the Pear installer automatically downloads any dependent packages.

pear install Net_Whois-1.0.2

Usage

The current library uses the following servers to execute the query:
whois.crsnic.net
whois.networksolutions.com
whois.nic.mil
whois.nic.gov
whois.arin.net
whois.ripe.net
whois.apnic.net
whois.ripn.net
whois.ra.net
.whois-servers.net
whois.6bone.net
whois.registro.br

A example code is shown below.

<?php
 
    require_once "Net/Whois.php";
 
    $whois = new Net_Whois();
    /* You can add other NIC server as a second parameter. */
    $info = $whois->query('example.com');
    echo($info);
 
?>

Note that the class returns a string, so you would need to use regular expressions to get to the relevant information.






3 Responses

1

Ricky

March 12th, 2009 at 11:31 pm

This is not works for me…..

sameer

March 13th, 2009 at 2:29 am

Whats the problem?

3

For Technical Information

April 22nd, 2009 at 7:12 am

I cant download the package net

Comments are disabled for this post, but if you have spotted an error, feel free to contact me.

Get latest updates by E-mail

About this blog

This site is a digital habitat of Sameer, a freelance web developer working from Pune.More

  • Users Online

    • 8 Users Online
    • 7 Guests, 1 Bot
  • RECENT COMMENTS

    ON TWITTER