批改状态:合格
老师批语:
<?phpnamespace auto;class autoLoad{public static function load($class){// 类名到类文件名// 1.将路径分隔符替换$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);$file = __DIR__ . '/' . $path . '.php';if ( is_file($file) && file_exists($file)){require $file;}else {die($file . '不存在');}}}
<?phpinclude "autoLoad.php";spl_autoload_register(["auto\autoLoad","load"]);use admin\controller\Index;use admin\model\User;use admin\view\index\Hello;$Index = new Index();$User = new User();$Hello = new Hello();echo Index::show() . PHP_EOL;echo User::show() . PHP_EOL;echo Hello::show() . PHP_EOL;


Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号