Forum Moderators: coopster
Will gethostbyname() [php.net] not work?
I found the *official* documentation when I clicked the author's name on the PEAR site and found a link to his home page. In his own words...
Documentation is still being written, although most of the major pieces are now complete. You can find my (poorly written) documentation at [ypass.net...]
Net_Dig [pear.php.net] class is no longer being maintained. Use of Net_DNS is recommended instead. A brief tutorial on how to migrate to Net_DNS is listed below.
I followed the link and found a step-by-step for you. I'll post the unlinked url and an example of how to use the code...
http://viebrock.ca/code/2/porting-netdig-to-netdns
<?php
require 'Net/DNS.php';
$D = new Net_DNS();
$result = $D->resolver->query('example.com');
print_r($result);
?>
To check if the query was successful and, if so, to output the IP address:<?php
if ( $result->header->rcode!= 'NOERROR' && $result->header->ancount > 0 ) {
echo $result->answer[0]->address;
}
?>