根据
PHP页面
原文链接:https://www.f2er.com/php/138044.htmlspl_autoload_register( )
的最高评论:
Good news for @R_301_461@ 5.3 users with namespaced classes:
When you create a subfolder structure matching the namespaces of the >containing classes,you will never even have to define an autoloader.
<?@R_301_461@ spl_autoload_extensions(".@R_301_461@"); // comma-separated list spl_autoload_register(); ?>
但是,当我有以下结构时:
* classes / someclass.@R_301_461@
* index.@R_301_461@
<?@R_301_461@ class someclass { function __construct( ) { echo 'It works!'; } } ?>
和index.@R_301_461@包含:
<?@R_301_461@ spl_autoload_extensions(".@R_301_461@"); spl_autoload_register(); new classes\someclass; ?>
然后我收到以下错误:
Fatal error: spl_autoload(): Class classes\someclass could not be
loaded
我错了吗?我怎样才能做到这一点?
从评论
这对于班级不起作用:
<?@R_301_461@ namespace classes; class someclass { function __construct( ) { echo 'It works!'; } } ?>