PHP namespacing and spl_autoload_register
问题 I had spl_autoload_register working fine but then I decided to add some namespacing to bring in PSR2 compliance and can't seem to get it working. Directory strcuture: -index.php -classes/ -Class1.class.php -Class2.class.php -Class3.class.php Each class starts with: namespace Foo; Class ClassX { Index.php: <?php spl_autoload_register(function($class) { include 'classes/' . $class . '.class.php'; }); $myObj = new Class1(); echo $myObj->doSomething(); This products an error Fatal error: Class