代码示例:
$car = new car(); $car->startLog(); trait trait_class { public function startLog(){ echo "start log"; } public function endLog(){ echo "end log"; } } class car { use trait_class; }
输出结果:start log
代码示例:
$car = new car(); $car->startLog(); trait trait_class { public function startLog(){ echo "start log"; } public function endLog(){ echo "end log"; } } class car { use trait_class; }
输出结果:start log