Jump to content

Autoload giving PEAR error


beingalex

Recommended Posts

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

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"

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

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.