Correction status:qualified
Teacher's comments:
trait可以实现代码的复用,下面用实例来演示一下:
<?php trait Course { public function study($course='php') { return '我们在php中文网学习'.$course; } } class Student { use Course; } $student = new Student(); echo $student->study();
点击 "运行实例" 按钮查看在线实例
运行结果: