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 Quote Link to comment 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? Quote Link to comment 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"; } } Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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" Quote Link to comment 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 Quote Link to comment 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.