我在我的項目目錄結構如下:如何在不帶參數的情況下使用spl_autoload_register?
Test
--Cats
----Fatty.php // namespace: Test\Cats
--index.php
的index.php:
spl_autoload_extensions(".php");
spl_autoload_register();
Test\Cats\Fatty::fattyMeow();
我得到的錯誤:
Fatal error: Class 'Test\Cats\Fatty' not found in /var/www/public/Test/index.php on line 9
據this在PHP評論.net,spl_autoload_register()
應該工作得很好沒有任何autoload
功能提供如果名稱空間匹配直接項目的結構。那麼,爲什麼上面的代碼不起作用?還是我誤解了某些東西?
什麼是你所得到的錯誤? –
我沒有看到Techniques文件夾也沒有看到Grumpy.php –
對不起,爲了簡化結構,我修改了一下 –