|
I'm flummoxed a bit. I recently upgraded from PHP 5.2 to 5.3 and my class files no longer autoload. I realize that 5.3 changed in that it now allows namespaces, but I haven't been able to find any resources on changes to autoloading. Is 5.3 backward compatible or are namespaces required? Or is there some PHP setting that I need to enable (I'm using XAMPP 1.7.2 as my localhost and haven't changed any of the default settings)? Ideally, I'd like to have my classes autoload in both 5.2 and 5.3.
Here's an example of the format I'm using for autoloading:
function __autoload($className) {
$className = str_replace('_', '/', $className);
require_once('includes/'.$className.'.php');
}
And the class:
class Example_Class_Two extends Example_Class_One {
function __construct(){
echo "I'm a function.";
}
}
I haven't made any changes to the code from when it worked in 5.2, but don't hesitate to point out the patently obvious because it may be that I'm missing something simple. Thanks!
|