批改状态:合格
老师批语:
类名与文件名相同,类是以class开头,类名首字母必须大写
成员属性要有访问修饰符
构造函数 类每实例化一次 自动被调用
成员方法
引用类文件过多,调用类的自动加载器
autoload.php
spl_autoload_register(function ($className) {printf('类名:%s<br>', $className);// var_dump(__DIR__);$file = __DIR__ . DIRECTORY_SEPARATOR . $className . '.php';if (!is_file($file) && file_exists(($file))) {throw new \Exception('文件不合法或者文件不存在');}require $file;});
在客户端 引用类的自动加载器
require ‘autoload.php’;
new关键字完成类的实例化
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号