Home arrow PHP arrow Page 4 - PHP Networking

Getting information about a domain name - PHP

PHP has a great many tools for interacting with a network and also with the Internet. In this article we will look at some of those tools and functions to see how we can use them to make our scripts more useful in a network environment. This article is the first of two parts.

TABLE OF CONTENTS:
  1. PHP Networking
  2. DNS and PHP
  3. DNS and PHP continued
  4. Getting information about a domain name
By: David Web
Rating: starstarstarstarstar / 4
September 08, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

When looking at a domain name as part of a email address or URL, you simply do not get enough information from it. You can even go so far as visiting that URL and you still will not have enough information about the ownership of that particular domain. Most of the kind of information that you would want will be located in a WHOIS database. These databases are maintained by registrars and can provide information about the owners of a particular domain. To get the information from these databases you need to run a whois query from a client application. PHP provides this kind of client application through the PEAR package.

PEAR has a class that enables you to query a whois database. This class is called Net_Whois. And is used like so:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>


<body>

<?

require_once "Net/Whois.php";

$server = "whois.networksolutions.com";

$query = "metroworks.com";

$whois = new Net_Whois;

$urlinfo = $whois->query($query, $server);

var_dump($urlinfo);

?>

</body>

</html>


First the code defines the server where the whois database is located:


$server = "whois.networksolutions.com";


Then it defines the name of the domain on which it wants to run a query:


$query = "metroworks.com";


Finally the query is run, after the Net_whois class is instantiated:


$whois = new Net_Whois;

$urlinfo = $whois->query($query, $server);


and the information from the query is shown:


var_dump($urlinfo);

The var_dump() function will show the entire contents of the $urlinfo variable.

Next week we will go over more PHP tools and functions that are useful in a network environment. 



 
 
>>> More PHP Articles          >>> More By David Web
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: