批改状态:合格
老师批语:
<?phpnamespace C {class Banji{//...}//1、非限定名称,访问当前空间下的类echo Banji::class;//2、限定名称,访问下级空间中的类echo C1\Banji::class;//3、完全限定名称,访问上级空间或者不属于该空间及下级空间的类echo \D\Banji::class;}namespace C\C1 {class Banji{//...}}namespace D {class Banji{//...}}
<?phpnamespace C {class Banji{const NAME = '动态类';//...}$dongtai = '\C\Banji';// echo '动态类'echo $dongtai::NAME;}
别名的使用有两个应用场景:1、简化长的名字 2、解决命名冲突
<?phpnamespace C\qq {class Banji{//...}//加载模块require '2-1.php';//当前类中有名字和引用类名重名时要使用别名use \C\weichat\Banji as grad;$bj = new grad;var_dump($bj);}
<?phpspl_autoload_register(function($class){$file = str_replace('\\',DIRECTORY_SEPARATOR,$class).'.php';require $file;});
数据定义 create alter drop
数据操作 insert delete update select
数据控制 grant revoke
事件控制 commit rollback
//创建数据库create database newphp;//删除数据库drop database newphp;//创建数据库并校验字符集create database newphp collate utf8mb4_unicode_ci;//查看建库语句show create database newphp;//创建数据表create table yuangong(yid int unsigned auto_increment primary key,name varchar(20) not null comment '姓名',gender enum('male','female') not null comment '性别',email varchar(100) not null comment '邮箱',birthday date not null comment '生日',create_at timestamp not null default current_timestamp comment '创建日期',updata_at timestamp not null default current_timestamp on update current_timestamp comment '更新日期') engine = innodb auto_increment = 1 collate utf8mb4_unicode_ci;//查看建表语句show create table yuangong;//查看库中所有的表show tables;//删除表操作drop table yuangong;//修改表操作//增加字段alter table yuangong add address varchar(100) comment '员工地址' after birthday;//更新字段alter table yuangong change address salary float unsigned not null default 3000 comment '员工工资' after birthday;//删除字段alter table yuangong drop address;//数据表操作CURD// mysql插入数据方法1insert yuangong(name,gender,salary,email,birthday)values('张三','male',5000,'zhangsan@163.com','1986-02-01');//mysql插入数据方法2insert yuangong set name='李四',gender='female',salary=3000,email='lisi@163.com',birthday='1984-02-21';
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号