Correction status:qualified
Teacher's comments:恭喜你终于终于搞明白了类的自动加载
user.php
<?php namespace controller\user; class user { public function demo() { return __CLASS__.'加载成功'; } }
点击 "运行实例" 按钮查看在线实例
demo1.php
<?php namespace app; use controller\user\user; spl_autoload_register(function ($classname) { $classname = str_replace('\\','/',$classname); require __DIR__.'/'.$classname.'.php'; }); echo (new user)->demo();
点击 "运行实例" 按钮查看在线实例