Page 1 of 1
autoload() issue
Posted: Tue Feb 28, 2006 6:54 am
by jmut
I am using autoload() to automatically include class.
What happens when I am using external class (from PEAR) for example.
Should hardcode in autoload() external class that I use and the it should load them?
P.S. Actually I cannot hardcode extgerna class...as this class might call other stuff

What should I do
Posted: Tue Feb 28, 2006 9:44 am
by feyd
utilize the include_path settings?
Posted: Wed Mar 01, 2006 1:46 am
by jmut
feyd wrote:utilize the include_path settings?
Yep that was the problem.
I just added my classes' path to include path and it all worked like a charm.
10xy
Posted: Wed Mar 01, 2006 3:29 am
by duk
when you meen "autoload()"
is something like this ?? im trying to understand when you mean autoload what it is in fact...
Code: Select all
?php
function __autoload($class_name) {
require_once $class_name . '.php';
}
$obj = new MyClass1();
$obj2 = new MyClass2();
?>
Posted: Wed Mar 01, 2006 3:51 am
by jmut
duk wrote:when you meen "autoload()"
is something like this ?? im trying to understand when you mean autoload what it is in fact...
Code: Select all
?php
function __autoload($class_name) {
require_once $class_name . '.php';
}
$obj = new MyClass1();
$obj2 = new MyClass2();
?>
exactly
just before I did something like
Code: Select all
function __autoload($class_name) {
require_once CLASS_PATH.$class_name . '.php';
}
and now I just included CLASS_PATH to include path and did it as you mention. (PEAR style....replacing "_" with "/")
So that external classes run as well
