PHP OOP 编程问题
你好 我得到了 php 课程的链接。我正在尝试制作一个域可用性检查器。我设法从那里获得一个域名 whois 类,但运行它时遇到问题。我已将该类包含在我的页面中,对其进行实例化并尝试运行示例代码。当我加载它时,它在我的网站上显示该类,然后在下面显示:致命错误:在第 8 行的 C:\wamp\www\tes.php 中找不到类“域”。我不明白我的路径如果它可以在屏幕上显示该类,显然是正确的。
这是我的代码。请记住,这是随该类提供的示例代码。
<?php
require_once('classes/domain.class.php');
$choice = 'amazing.co.uk';
// Initializing class
$domain=new domain($choice);
// Printing out whois data
echo $domain->info()."<br>";
// Printing out whois data in HTML format
echo $domain->html_info()."<br><br>";
// Checking if domain is available
if($domain->is_available()){
echo "Domain is available<br>";
}else{
echo "Domain is not Available<br>";
}
// Printing out whois host of domain
echo "Whois Server: ".$domain->get_whois_server()."<br>";
// Printing out name of domain without tld
echo "Domain: ".$domain->get_domain()."<br>";
// Printing out tld name of domain
echo "Tld: ".$domain->get_tld()."<br>";
// Checking if domain name is valid
if($domain->is_valid()){
echo "Domain name is valid!<br>";
}else{
echo "Domain name isn't valid!<br>";
}
// Getting all suppoerted TLD's
$tlds=$domain->get_tlds();
for($i=0;$i<count($tlds);$i++){
echo $tlds[$i]."<br>";
}
?>
预先感谢并感谢所有帮助。
问候 乔
Hi
I was given a link to php classes. I am trying to make a domain availability checker. I managed to get a domain whois class from there but having a problem running it. I have included the class in my page, instatiated it and tried to run the example code. When i load it, it is displaying the class on my site and then below saying: Fatal error: Class 'domain' not found in C:\wamp\www\tes.php on line 8. I don't get it my path is obviously right if it can display the class on screen.
Heres my code. Please bear in mind this is the example code that was supplied with the class.
<?php
require_once('classes/domain.class.php');
$choice = 'amazing.co.uk';
// Initializing class
$domain=new domain($choice);
// Printing out whois data
echo $domain->info()."<br>";
// Printing out whois data in HTML format
echo $domain->html_info()."<br><br>";
// Checking if domain is available
if($domain->is_available()){
echo "Domain is available<br>";
}else{
echo "Domain is not Available<br>";
}
// Printing out whois host of domain
echo "Whois Server: ".$domain->get_whois_server()."<br>";
// Printing out name of domain without tld
echo "Domain: ".$domain->get_domain()."<br>";
// Printing out tld name of domain
echo "Tld: ".$domain->get_tld()."<br>";
// Checking if domain name is valid
if($domain->is_valid()){
echo "Domain name is valid!<br>";
}else{
echo "Domain name isn't valid!<br>";
}
// Getting all suppoerted TLD's
$tlds=$domain->get_tlds();
for($i=0;$i<count($tlds);$i++){
echo $tlds[$i]."<br>";
}
?>
Thanks in advance and all help appreciated.
Regards
Joe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决这个问题的好步骤。
检查定义类的行,它应该类似于:
类域
{
/*...*/
}
确保类名相同。
注意:请记住,要使 php 文件在运行时可用,它必须在类文件的第一行有一个起始
。
Ok steps to resolving this.
Check the line that defines the class, it should look something like:
class domain
{
/*...*/
}
Make sure that the class name is the same.
Note: Remember for a php file to be avalaible at runtime it must have a starting
<?php
at the first line of your class file.类域可能未定义在:classes/domain.class.php
The class domain is probably not defined in: classes/domain.class.php