排除“找不到类”错误

时间:2012-06-05 00:47:29

标签: php whois

任何人都告诉我为什么我收到错误“Class'Whois'未找到”。这与行$whois = new Whois();有关,但我不确定是什么。

<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>

2 个答案:

答案 0 :(得分:0)

我认为您应该将require_once移到文件的顶部。

答案 1 :(得分:0)

确保从正确的目录中加载

require_once("whois.class.php");