简体   繁体   English

PHP OOP编程问题

[英]PHP OOP programming question

Hi I was given a link to php classes. 嗨,我获得了php类的链接。 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. 我设法从那里得到一个域名whois类,但是运行它时遇到了问题。 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. 当我加载它时,它在我的网站上显示该类,然后在下面说:致命错误:在第8行的C:\\ wamp \\ www \\ tes.php中找不到类'domain'。我没有得到它如果可以在屏幕上显示课程,那显然是正确的。

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 问候乔

类域可能未在以下类中定义:classes / domain.class.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. 注意:请记住,要使php文件在运行时可用,它必须在类文件的第一行以<?php开头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM