PHP Autoload Issue
by Jason on September 11, 2008
On a recent project, I couldn’t figure out why the following block of code worked on OSX but not Red Hat Linux.
function __autoload($class_name) {
require_once 'lib/' . $class_name . '.class.php';
}
I had a class named ‘bank.class.php’ which autoload was attempting to find. It worked properly on OSX, however on Linux it wouldn’t work. I quickly discovered that Linux required the file to be renamed to ‘Bank.class.php’. Alternatively I could have changed the autoload to:
function __autoload($class_name) {
require_once 'lib/' . strtolower($class_name) . '.class.php';
}
Leave your comment