Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Networking With PEAR
Trawl the archives for PHP versions of common networking tools

| What's In A Name? |

Need the IP address for a domain, but don't have access to PHP's built-in DNS functions? Use PEAR's Net_DNS package from http://pear.php.net/package/Net_DNS, a sophisticated toolkit which lets you indulge in all manner of DNS trickery. This package actually contains a series of different classes, each one performing a different task; however, the one you're most likely to use is the Net_DNS_Resolver class, which lets you resolve domain names to IP addresses, and vice-versa. Here's an example of it in action:


<?php
// include class
include("Net/DNS.php");

// initialize object
$dns = new Net_DNS_Resolver();

// perform DNS query
$result = $dns->search("example.com");
print_r($result);
?>


In this example, the search() method queries the name server to retrieve DNS records for the domain example.com.

You can force the search() method to query for a particular type of domain record - for example, a CNAME or MX record - by adding the record type to the search() method call. Here's an example:


<?php
// include class
include("Net/DNS.php");

// initialize object
$dns = new Net_DNS_Resolver();

// perform DNS query
$result = $dns->search("yahoo.com", "MX");
print_r($result);
?>


It's important to note that the Net_DNS class doesn't depend on system libraries to perform DNS lookups; instead, it directly communicates with the DNS server using a socket connection. In order to do this, it depends on information in the system's resolv.conf file. If this file is not present, the Net_DNS package will not function correctly.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback