0

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

6
  • bah, just parse the whois output yourself. It is trivial. Commented Feb 16, 2011 at 23:06
  • Please post the content of 'classes/domain.class.php' (at least the first few lines and the end). With the content of that file, it's hard to find a bug. Commented Feb 16, 2011 at 23:06
  • Instead you might try using pear.php.net/net_whois - gives you a very easy way to do this. Commented Feb 16, 2011 at 23:07
  • Within domain.class.php what does the line say class _____{ Commented Feb 16, 2011 at 23:07
  • "displayed the class on my site" ... like it output the code into the page? That sounds like the included file doesn't have the <?php tag in it (or it's corrupted somehow) Commented Feb 16, 2011 at 23:13

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

class was defined correct but the class id downloaded was using short tags and WAMP didnt like that so failed lol But now its saying functions are depricated "Deprecated: Function split() is deprecated in " does that mean that the class ive downloaded is pretty much useless.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.