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
https://forums.phpfreaks.com/topic/201448-extended-classes-not-being-found/
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";
}

: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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.