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
你使用的是默認(rèn)的spl_autoload() 函數(shù),這個(gè)函數(shù)的默認(rèn)extension參數(shù)是會把類名自動(dòng)轉(zhuǎn)換為小寫,在加上后綴名也就是spl_autoload_extensions()設(shè)置的后綴。
如果想要實(shí)現(xiàn)大寫,你可以自己實(shí)現(xiàn)一個(gè)類加載方法, 讓后spl_autoload_register() 注冊這個(gè)函數(shù),這樣應(yīng)該可以滿足你的DIY 需求。這種方式也是很多PHP框架實(shí)現(xiàn)的方式
2015-03-01
找到原因了,類名要小寫,Test.class.php,不行,需要test.class.php