Jump to content

NET_DNS Help


jhyatt1271

Recommended Posts

In the following code I get a response but I would like to be able to put this into a string to edit the output to something more suitable to my needs.

 

Can anyone point me in the right direction?

 

require_once 'Net/DNS.php';

$resolver = new Net_DNS_Resolver();
$resolver->nameservers = array('4.2.2.1');
	   
$response = $resolver->query('phpfreaks.com', 'A');

  foreach ($response->answer as $rr)
  {
    $rr->display();
  }

 

It displays this on the page.

phpfreaks.com. 120 IN A 66.97.171.5

 

When I try to grab the response out and explode it with this code

  foreach ($response->answer as $rr)
  {
	$ev = explode(" ", $rr); //<----------- line 16
for($i = 0; $i < count($ev); $i++)
{
echo "Line$i = $ev[$i] <br />";
}
  }

 

I get the following error

Catchable fatal error: Object of class Net_DNS_RR_A could not be converted to string on line 16

 

 

Link to comment
https://forums.phpfreaks.com/topic/170015-net_dns-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.