尝试自动加载类时出现此错误

I get this error when trying to autoload classes.

I declare this class in myclass.php file and instantiate it in test.php. but i got class not found error on xammp. Is _autoload function case sensitive in php.

class MyClass {
//some properties and methods
}

function __autoload($class_name) {
require_once($class_name.".php"); 
}

$myclass = new MyClass();

Anyone know what the problem is?

Make sure you define MyClass correctly in your myclass.php.Your problem is not caused by __autoload because the error is class not found instead of file not found which require_once would throw out if it fails.

Class names and function names in PHP are not case-sensitive, but your autoloader must use the correct case when using require* or include* because your OS filesystem may be case-sensitive. And if your autoloader uses relative paths, make sure the classes invoked are in PHP's include_path.