Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to modify this code?

Posted on 2009-02-21
4
Medium Priority
?
209 Views
Last Modified: 2012-05-06
Hi Folks, I have some code to query a domain but now I'd like to query multiple domains at once using a for loop or something.
Perhaps the supplied code can be turned into a function which takes a domain as param?  If you need more info please ask.

Regards Peter
<?php
require_once "Whois.php";
 
$server = "whois.denic.de";
$query  = "autoverzekering-tarieven.nl";     // get information about  this domain
$whois = new Net_Whois;
$data = $whois->query($query, $server);
echo $data;
?>

Open in new window

0
Comment
Question by:PeterdeB
  • 2
4 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 23700896

<?php
function my_whois($array)
{
   require_once "Whois.php";
   $answers = array();
   $server = "whois.denic.de";
   foreach ($array as $query)
   {
      $whois = new Net_Whois;
      $answers["$query"] = $whois->query($query, $server);
      unset($whois);
   }
   return($answers);
}
?>

Open in new window

0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 23700898
In the example above, you pass as input an array of domains to query.  The return value is an associative array with the domain as the key and the query result as the value.

HTH, ~Ray
0
 
LVL 16

Expert Comment

by:Robin
ID: 23700899
Using it as a function, will get you this:

Will this do?
<?php
require_once "Whois.php";
 
function getWhoisData($domain)
{
  $server = "whois.denic.de";
  $whois = new Net_Whois;
  return $whois->query($domain, $server);
}
 
echo getWhoisData("autoverzekering-tarieven.nl");
echo getWhoisData("fietsverzekering-tarieven.nl");
//etc.
 
?>

Open in new window

0
 

Author Comment

by:PeterdeB
ID: 23701193
Thanks for the replies folks.
@Ray > I will post another question in an attempt to use the function you supplied.

Regards,

Peter
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question