Use this PHP class script the whois information for domain names. You can check if a domain is free or you can request the detailed whois information for already registered domain names. The whois information is used by domain name hosting providers or by a user who is looking for a free (or registered) domain name. The PHP Whois script comes with different example files to show you how to use the PHP class for single and multiple domain name requests.

The PHP Whois class works with TLD’s (top-level domain names) where a whois server is available. You can choose which domain name extensions (tld) the script should support. A complete whois server list is attached to this page.

Visit here the Script DemoPHP Script Download

How does it work?

Try the basic whois domain example script first.

  1. Create on your web server the following directory structure: Your_Public_Folder/classes/whois/ (Your_Public_Folder is the directory where your site’s homepage is located).
  2. Upload the class file named “whois_class.php” into this newly created directory.
  3. Upload the PHP Whois example file “whois_example.php” to your server as well and access the file in your browser.
  4. Enter into the form field the first part from a domain name and choose an extension from the select menu.
  5. Optional: Use the checkbox “Show all info?” to get also the whois information for a valid domain name.
  6. Click the submit button.

More example files:

multi_whois_list.php and multi_whois_detail.php
These two files check a) multiple domain names in a single request and b) the detail page show the whois detail (if available)

This file is an example how to redirect the user to the next page, for example the step2 in a domain name order process.

Adding more tlds

Open the file “server_list.php” and notice that every Whois server entry has three array elements: The whois server name, the “is free” string and an optional parameter (you need to check the specific Whois server website to check if they are required).

$servers['xx']['address'] = "whois.xx";
$servers['xx']['free'] = "FREE";
$servers['x']['param'] = "";

Replace xx with your new tld, address is the address you need for your query. The free string is something you can find on the Internet or while using the script name whois_servertest.php

You can add to this list as many TLD’s you need, check the Whois server list below for the details.

Complete Whois server list

TLD Country Whois server Type
ac Ascension Island Country Code
academy Generic
accountants Generic
active Generic
actor Generic
ae United Arab Emirates Country Code
aero Sponsored
af Afghanistan Country Code
ag Antigua And Barbuda Country Code
agency Generic
ai Anguilla Country Code
airforce Generic
am Armenia Country Code
archi Generic
army Generic
arpa Infrastructure
as American Samoa Country Code
asia Sponsored
associates Generic
at Austria Country Code
attorney Generic
au Australia Country Code
auction Generic
audio Generic
autos Generic
aw Aruba Country Code
ax Åland Islands Country Code
bar Generic
bargains Generic
bayern Generic
be Belgium Country Code
beer Generic
berlin Generic
best Generic
bg Bulgaria Country Code
bike Generic
bio Generic
bi Burundi Country Code
black Generic
blackfriday Generic
blue Generic
biz Generic Restricted
bj Benin Country Code
bmw Generic
bn Brunei Darussalam Country Code
bo Bolivia Country Code
boutique Generic
br Brazil Country Code
brussels Generic
build Generic
builders Generic
bw Botswana Country Code
bzh Generic
ca Canada Country Code
cab Generic
camera Generic
camp Generic
cancerresearch Generic
capetown Generic
capital Generic
cards Generic
care Generic
career Generic
careers Generic
cash Generic
cat Sponsored
catering Generic
center Generic
ceo Generic
cf Central African Republic Country Code
ch Switzerland Country Code
cheap Generic
christmas Generic
church Generic
ci Cote d’Ivoire Country Code
city Generic
cl Chile Country Code
claims Generic
cleaning Generic
clinic Generic
clothing Generic
club Generic
cn China Country Code
co Colombia Country Code
codes Generic
coffee Generic
college Generic
cologne Generic
com Generic
community Generic
company Generic
computer Generic
condos Generic
construction Generic
consulting Generic
contractors Generic
cooking Generic
cool Generic
country Generic
credit Generic
creditcard Generic
cruises Generic
coop Sponsored
cuisinella Generic
cx Christmas Island Country Code
cz Czech Republic Country Code
dance Generic
dating Generic
de Germany Country Code
deals Generic
dental Generic
degree Generic
democrat Generic
dentist Generic
desi Generic
diamonds Generic
digital Generic
direct Generic
directory Generic
discount Generic
dk Denmark Country Code
dm Dominica Country Code
domains Generic
durban Generic
dz Algeria Country Code
edu Sponsored
ec Ecuador Country Code
education Generic
ee Estonia Country Code
engineer Generic
email Generic
engineering Generic
enterprises Generic
equipment Generic
estate Generic
es Spain Country Code
eu Europe Country Code
eus Generic
events Generic
exchange Generic
expert Generic
exposed Generic
fail Generic
farm Generic
feedback Generic
fi Finland Country Code
finance Generic
financial Generic
fish Generic
fitness Generic
fishing Generic
flights Generic
florist Generic
fo Faroe Islands Country Code
foo Generic
foundation Generic
fr France Country Code
frogans Generic
fund Generic
furniture Generic
futbol Generic
gal Generic
gallery Generic
gd Grenada Country Code
gent Generic
gg Guernsey Country Code
gi Gibraltar Country Code
gift Generic
gives Generic
gl Greenland Country Code
glass Generic
global Generic
globo Generic
gop Generic
gov Sponsored
graphics Generic
gratis Generic
green Generic
gripe Generic
gs South Georgia And The South Sandwich Islands Country Code
guide Generic
guitars Generic
guru Generic
gy Guyana Country Code
hamburg Generic
haus Generic
healthcare Generic
hiphop Generic
hiv Generic
hk Hong Kong Country Code
hn Honduras Country Code
holdings Generic
holiday Generic
home Generic
horse Generic
host Generic
house Generic
hr Croatia Country Code
ht Haiti Country Code
id Indonesia Country Code
ie Ireland Country Code
il Israel Country Code
im Isle of Man Country Code
immobilien Generic
in India Country Code
industries Generic
ink Generic
institute Generic
insure Generic
int Sponsored
international Generic
investments Generic
info Generic
io British Indian Ocean Territory Country Code
iq Iraq Country Code
ir Islamic Republic Of Iran Country Code
is Iceland Country Code
it Italy Country Code
je Jersey Country Code
jobs Sponsored
joburg Generic
jp Japan Country Code
juegos Generic
kaufen Generic
ke Kenia Country Code
kg Kyrgyzstan Country Code
ki Kiribati Country Code
kim Generic
kitchen Generic
kiwi Generic
koeln Generic
krd Generic
kr Republic Of Korea Country Code
kz Kazakhstan Country Code
la People’s Democratic Republic Lao Country Code
lacaixa Generic
land Generic
lawyer Generic
lease Generic
lgbt Generic
li Liechtenstein Country Code
life Generic
lighting Generic
limited Generic
limo Generic
link Generic
loans Generic
london Generic
lotto Generic
lt Lithuania Country Code
lu Luxembourg Country Code
luxe Generic
luxury Generic
lv Latvia Country Code
ly Libya Country Code
ma Morocco Country Code
maison Generic
management Generic
mango Generic
market Generic
marketing Generic
md Republic Of Moldova Country Code
me Montenegro Country Code
media Generic
meet Generic
melbourne Generic
menu Generic
mg Madagascar Country Code
miami Generic
mini Generic
mk The Former Yugoslav Republic Of Macedonia Country Code
ml Mali Country Code
mn Mongolia Country Code
mo Macao Country Code
mobi Generic
moda Generic
monash Generic
mortgage Generic
moscow Generic
motorcycles Generic
mp Northern Mariana Islands Country Code
ms Montserrat Country Code
mu Mauritius Country Code
museum Sponsored
mx Mexico Country Code
my Malaysia Country Code
na Namibia Country Code
name Generic Restricted
navy Generic
nc New Caledonia Country Code
net Generic
nf Norfolk Island Country Code
ng Nigeria Country Code
ngo Generic
ninja Generic
nl The Netherlands Country Code
no Norway Country Code
nra Generic
nrw Generic
nu Niue Country Code
nz New Zealand Country Code
om Oman Country Code
onl Generic
org Generic
organic Generic
ovh Generic
paris Generic
partners Generic
parts Generic
pe Peru Country Code
pf French Polynesia Country Code
photo Generic
photography Generic
photos Generic
physio Generic
pics Generic
pictures Generic
pink Generic
pl Poland Country Code
place Generic
plumbing Generic
pm Saint Pierre and Miquelon Country Code
post Sponsored
pr Puerto Rico Country Code
press Generic
pro Generic-restricted
productions Generic
properties Generic
pt Portugal Country Code
pub Generic
pw Palau Country Code
qa Qatar Country Code
quebec Generic
re Réunion Country Code
recipes Generic
red Generic
rehab Generic
reise Generic
reisen Generic
rentals Generic
repair Generic
report Generic
republican Generic
rest Generic
review Generic
rich Generic
rio Generic
ro Romania Country Code
rocks Generic
rodeo Generic
rs Serbia Country Code
ru Russian Federation Country Code
ruhr Generic
sa Saudi Arabia Country Code
saarland Generic
sb Solomon Islands Country Code
sc Seychelles Country Code
scb Generic
schmidt Generic
schule Generic
scot Generic
se Sweden Country Code
services Generic
sexy Generic
sg Singapore Country Code
sh Ascension And Tristan Da Cunha Saint Helena Country Code
shiksha Generic
shoes Generic
si Slovenia Country Code
singles Generic
sk Slovakia Country Code
sm San Marino Country Code
sn Senegal Country Code
so Somalia Country Code
social Generic
software Generic
solar Generic
solutions Generic
soy Generic
space Generic
spiegel Generic
st Sao Tome And Principe Country Code
su Soviet Union Country Code
supplies Generic
supply Generic
support Generic
surf Generic
surgery Generic
sx Sint Maarten Country Code
sy Syrian Arab Republic Country Code
systems Generic
tattoo Generic
tax Generic
tc Turks And Caicos Islands Country Code
technology Generic
tel Sponsored
tf French Southern and Antarctic Lands Country Code
th Thailand Country Code
tienda Generic
tips Generic
tirol Generic
tk Tokelau Country Code
tl Timor-leste Country Code
tm Turkmenistan Country Code
tn Tunisia Country Code
to Tonga Country Code
today Generic
tools Generic
top Generic
town Generic
toys Generic
tr Turkey Country Code
training Generic
travel Sponsored
tv Tuvalu Country Code
tw Taiwan Country Code
tz United Republic Of Tanzania Country Code
ua Ukraine Country Code
ug Uganda Country Code
uk United Kingdom Country Code
university Generic
us United States of America Country Code
uy Uruguay Country Code
uz Uzbekistan Country Code
vacations Generic
vc Saint Vincent And The Grenadines Country Code
ve Bolivarian Republic Of Venezuela Country Code
vegas Generic
ventures Generic
versicherung Generic
vet Generic
vg British Virgin Islands Country Code
viajes Generic
villas Generic
vision Generic
vlaanderen Generic
vodka Generic
vote Generic
voting Generic
voto Generic
voyage Generic
vu Vanuatu Country Code
wales Generic
wang Generic
watch Generic
website Generic
wed Generic
wf Wallis and Futuna Islands Country Code
wien Generic
wiki Generic
works Generic
ws Samoa Country Code
wtc Generic
wtf Generic
xxx Sponsored
xyz Generic
yachts Generic
yt Mayotte Country Code
zm Zambia Country Code
zone Generic

Disclaimer: The data from this list is based on the information provided by the root zone database on There is no guaranty that all information on this list is correct and/or complete. We advice to check also the registry information before you use the information in your own whois script. Please report missing or wrong data by using our contact form.

Whois server test

There is a small script that you can use to check the response for a query with each whois server. Open the file “whois_servertest.php” and change the value for the whois server and domain name. Run the PHP script in your browser or from the command line.

function get_whois_data($test_server, $test_domain) {
	$msg = "";
	$connection = fsockopen($test_server, 43, $errno, $errstr, 10);
	if (!$connection) {
		$msg = "Can't connect to the server!";
	} else {
		fputs($connection, $test_domain."\r\n");
		while (!feof($connection)) {
			$msg[] = fgets($connection, 4096);
	return $msg;
print_r(get_whois_data("", ""));

Change log for the PHP Whois script

Version 1.22

Added additional whois server settings (.eu, .us) and the regex pattern is more improved.

Version 1.21

There was small problem if the user requests data about .de domein (denic), the exec function will not work for this kind of TLD. I put in the method get_whois_data() an if clause to use for this kind of TLD always a socket connection.

Version 1.20

I changed in this class the simple domain check and the method to obtain whois data, because there are several problems with timeouts by calling the whois servers. In this version there are two ways to get the whois data: the old method with fsockopen and (new) via the Linux command line with the command “whois -h”. The last one is much faster and uses features like re-directing. The class is modified to handle .nl queries while using the “is” parameter.

Version 1.13

I added a boolean to the check_only() method to use this information for domain register pages. You can use this “bool” to redirect to an other page (to sell the free name f.e.).

Version 1.12

I changed the get_whois_data() and the check_only() method, because the information was not right if there was no server connection. This class works now for PHP with the setting register_globals = off.

Version 1.11

I added the var $whois_param, use this var via the serverlist to use extra (required) parameters for some whois servers.

Version 1.10

In this version it’s possible to check domain names for all TLDs which are configured inside the server list. New Files: “multi_whois_list.php”, this file is an example for using the new functions and is also an extended version of the main class. “multi_whois_detail.php”, you need this file to get detailed information about domain names checked via the multi whois list file.