Fatal error: spl_autoload(): Class Test could not be loaded in /home/vilay/www/spl/index.php
spl_autoload_extensions('.class.php');
? ? define('CLASS_DIR','Class/');
? ? set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR);
? ? spl_autoload_register();
? ? new Test();
2016-11-02
你使用的是默認的spl_autoload() 函數,這個函數的默認extension參數是會把類名自動轉換為小寫,在加上后綴名也就是spl_autoload_extensions()設置的后綴。
如果想要實現大寫,你可以自己實現一個類加載方法, 讓后spl_autoload_register() 注冊這個函數,這樣應該可以滿足你的DIY 需求。這種方式也是很多PHP框架實現的方式
2015-03-01
找到原因了,類名要小寫,Test.class.php,不行,需要test.class.php