Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:等学到数据库知识就会了
// interface 接口
interface iUser
{
// 接口常量
const ZHANG = 'admin';
const MIMA = '123456';
}
//extends 继承iUser
interface iUserqita extends iUser
{
const MIBAO = '18868689999';
const YOUX = '123456@qq.com';
}
//实现多继承
interface iUserz extends iUserqita
{
// 接口方法
public function write();
}
// 实现类
class User implements iUserz
{
// 必须实现接口中的抽象方法
public function write()
{
return ' 账户: ' . iUser::ZHANG . ' 密码: ' . iUser::MIMA ;
}
//增加一个方法
public function write2()
{
return ' 密保手机: ' . iUserqita::MIBAO . ' 邮箱: ' . iUserqita::YOUX ;
}
}
echo ( new User)->write();
echo '<hr>';
echo ( new User)->write2();
trait tUserdy
{
// trait 定义一个方法 格式化打印
public function write()
{
$props =get_class_vars(__CLASS__);
printf('<pre>%s</pre>', print_r($props, true));
}
}
class iUsers1
{
//多复用trait tUserdy
use tUserdy;
//公开属性
public $zhang = 'admin';
public $mima = '123456';
public $xingqi = ['刷抖音','看新闻','听鬼故事'];
}
class iUsers2
{
//多复用trait tUserdy
use tUserdy;
//公开属性
public $zhang = 'xiaofei';
public $mima = '516156151';
public $xingqi = ['玩游戏','唱歌','看电影'];
}
(new iUsers1)->write();
(new iUsers2)->write();
总结:老师课程里面讲的接口连接数据库的两种方法,和四种操作大体能看懂,但是里面连接数据库和执行具体内容看不懂,所以举例就举了个简单的,~~(>_<)~~