Jump to content

extended classes not being found?


fivestringsurf

Recommended Posts

For some reason php5 is not finding my parent classes and is throwing the following error...

Fatal error: Class 'One' not found...

I am using xampp locally and extending my custom classes was working fine a few weeks ago.

Is it the include_path in php.ini perhaps?  I don't recall changing it, and just for the record it is set at:

include_path = ".;C:\xampp\php\PEAR"

Even in a simple class test with this is no longer working:

One.php

<?php
class One {
public function __construct(){
	echo 'test class one';
}
}
?>

Two.php

<?php
class two extends One {
}
$two = new two();
?>

 

I restarted apache....still no luck?

totally stumped here and would appreciate some insight.

Thanks

Link to comment
Share on other sites

You need to include the class declaration. Even if you have the include_path configuration option set to include the directory where your class definitions can be found it won't work unless it's being included. The include_path configuration setting is often mentioned in situations like this where you're using an autoloader to load classes. Ex:

 

function __autoload($classname)
{
     require_once "$classname.php";
}

Link to comment
Share on other sites

:D

uhggg.  (as i smack my head!) I wasn't including the file itself...I've been doing too much AS3 in which classes are automatically found....I forgot i must include them in php  Don't you just love mixing up languages...I'm sure it will get worse as i get older:)

Thanks guys for the help and AlexWD- Ive used the special __autoload function before it rocks!( but of course forgot about that one too)  ok...back to work.

 

Thanks again to all who contribute!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.