beingalex Posted May 4, 2010 Share Posted May 4, 2010 Hi guys. Is there any reason why: function __autoload($class_name) { require_once $class_name . ".class.php"; } is returning: Warning: require_once(PEAR_Error.class.php) [function.require-once]: failed to open stream: No such file or directory in E:/blah blah blah/index.php on line 9 The class name "LiveGallery.class.php" is in the right location. I'm tearin my hair out! Thanks for any help in advance - Alex Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/ Share on other sites More sharing options...
Mchl Posted May 4, 2010 Share Posted May 4, 2010 Apparently this LiveGallery class requires a PEAR_Error class. Do you have it? Is it in your include path? Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/#findComment-1052902 Share on other sites More sharing options...
beingalex Posted May 4, 2010 Author Share Posted May 4, 2010 Hi, LiveGallery.class.php is just; class LiveGallery { public function __construct() { echo "here"; } } Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/#findComment-1052906 Share on other sites More sharing options...
Mchl Posted May 4, 2010 Share Posted May 4, 2010 Something IS trying to require a PEAR_Error class, so look for it. For PEAR working correctly you need a slightly different autolaoding function, because they use a different naming scheme. Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/#findComment-1052907 Share on other sites More sharing options...
beingalex Posted May 4, 2010 Author Share Posted May 4, 2010 I created an empty file called "PEAR_Error.php" and put it in the directory that LiveGallery.class.php is in which made it work. Why is this file being called in the first place ? I am confused. Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/#findComment-1052915 Share on other sites More sharing options...
nhojeinnor Posted May 4, 2010 Share Posted May 4, 2010 Hi guys. Is there any reason why: function __autoload($class_name) { require_once $class_name . ".class.php"; } is returning: Warning: require_once(PEAR_Error.class.php) [function.require-once]: failed to open stream: No such file or directory in E:/blah blah blah/index.php on line 9 The class name "LiveGallery.class.php" is in the right location. I'm tearin my hair out! Thanks for any help in advance - Alex function __autoload($class_name) { require_once $class_name.".class.php"; } is ".class.php"? try "class.php" Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/#findComment-1052927 Share on other sites More sharing options...
beingalex Posted May 4, 2010 Author Share Posted May 4, 2010 Hi nhojeinnor, That wasn't it either. :-( However... I've worked it out... function __autoload($class_name) { $location = "inc/func/components/{$class_name}/{$class_name}.class.php"; if (file_exists($location)) require_once $location; } Wacked a check to see if the file exists. It was looking for PEAR_Error but I don't have it. Still a little baffled about this but I think it was because I dont have PEAR installed. Anyhoo! That'll do for now. Thanks Link to comment https://forums.phpfreaks.com/topic/200647-autoload-giving-pear-error/#findComment-1052937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.