PHP OOP 编程问题

发布于 2024-10-17 21:55:11 字数 1351 浏览 8 评论 0原文

你好 我得到了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吾家有女初长成 2024-10-24 21:55:11

解决这个问题的好步骤。

  • 打开类文件:
  • 检查定义类的行,它应该类似于:

    类域
    {
    /*...*/
    }

确保类名相同。

注意:请记住,要使 php 文件在运行时可用,它必须在类文件的第一行有一个起始

Ok steps to resolving this.

  • Open up the class file:
  • 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.

老娘不死你永远是小三 2024-10-24 21:55:11

类域可能未定义在:classes/domain.class.php

The class domain is probably not defined in: classes/domain.class.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文