Anyone tell me why I'm getting the error "Class 'Whois' not found". It's something to do with the line $whois = new Whois(); but I'm not sure what.

<form method="post" action="">
  <div style="margin:auto;width:300px;">
  <label for="domain name">Domain Check:</label><br />
  <input type="text" name="domain" /><br /><br />
  <input type="submit" />
</form>
<br />
<?php
if (isset($_REQUEST['domain'])) { // check to see if form has been submitted
function getwhois($domain, $tld)
{
require_once("whois.class.php");

$whois = new Whois();

if( !$whois->ValidDomain($domain.'.'.$tld) ){
    return 'Sorry, the domain is not valid or not supported.';
    }

if( $whois->Lookup($domain.'.'.$tld) ){
    return $whois->GetData(1);
    }else{
    return 'Sorry, an error occurred.';
    }
}

$domain = trim($_REQUEST['domain']);

$dot = strpos($domain, '.');
$sld = substr($domain, 0, $dot);
$tld = substr($domain, $dot+1);

$whois = getwhois($sld, $tld);

echo "

";
echo $whois;
echo "
";
}
?>
</div>
有帮助吗?

解决方案

Make sure you're loading this from the right directory

require_once("whois.class.php");

其他提示

I think you should move the require_once to the top of your file.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top