fivestringsurf Posted May 12, 2010 Share Posted May 12, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/201448-extended-classes-not-being-found/ Share on other sites More sharing options...
trq Posted May 12, 2010 Share Posted May 12, 2010 Are you actually including the class definitions where they are needed? Quote Link to comment https://forums.phpfreaks.com/topic/201448-extended-classes-not-being-found/#findComment-1056907 Share on other sites More sharing options...
lostnucleus Posted May 12, 2010 Share Posted May 12, 2010 in class two.php r u doing require_once('One.php'); if not then try that first , if that doesnt work do <?php phpinfo(); ?> run the above and check the value of "include_path" . Quote Link to comment https://forums.phpfreaks.com/topic/201448-extended-classes-not-being-found/#findComment-1056939 Share on other sites More sharing options...
Alex Posted May 12, 2010 Share Posted May 12, 2010 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/201448-extended-classes-not-being-found/#findComment-1056943 Share on other sites More sharing options...
fivestringsurf Posted May 12, 2010 Author Share Posted May 12, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/201448-extended-classes-not-being-found/#findComment-1057355 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.