我在我的项目目录结构如下:如何在不带参数的情况下使用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 –
对不起,为了简化结构,我修改了一下 –