PHP Trait续
来源:互联网 发布:软件测试工程师学习 编辑:程序博客网 时间:2024/06/05 06:39
//如果Trait 父类 和 子类中都同时包含一个方法,最后保留的是Trait
中的方法
class Person {
public function hello() {
echo "hello person<br/>";
}
public function driving() {
echo "driving from person<br/>";
}
}
class Student extends Person {
use Drive;
public function hello() {
echo "hello student<br/>";
}
}
trait Drive {
public function hello() {
echo "hello drive<br/>";
}
public function driving() {
echo "driving from drive<br/>";
}
}
$student = new Student();
$student->hello();
$student->driving();
中的方法
class Person {
public function hello() {
echo "hello person<br/>";
}
public function driving() {
echo "driving from person<br/>";
}
}
class Student extends Person {
use Drive;
public function hello() {
echo "hello student<br/>";
}
}
trait Drive {
public function hello() {
echo "hello drive<br/>";
}
public function driving() {
echo "driving from drive<br/>";
}
}
$student = new Student();
$student->hello();
$student->driving();
阅读全文
0 0
- PHP Trait续
- PHP Trait 续2
- php trait
- php trait
- PHP TRAIT
- PHP Trait
- PHP trait
- php trait
- PHP Trait
- php-Trait
- php trait
- php trait
- php trait 使用方法
- php手册之Trait
- php trait特性
- php的trait特性
- php中的trait
- php中的trait
- 互联网世界的“人工智能”——探秘“深度学习”的前世今生
- c语言 随机函数详解
- nifi-集群搭建,新增用户
- 第五次作业
- JUnit initializationError解决
- PHP Trait续
- MPAndroidChart之LineChart源码分析
- C++之继承
- C语言结构体数组
- kafka数据可靠性深度解读
- 决定开始写博客
- springmvc json 响应http406解决
- WCF 消息推送
- 基于ICMP协议的ping程序实现