<?php
trait student {
public $name;
public function say() {
printf('I\'m %s. ', $this->name);
}
public function eat() {
printf('<br>%s', __TRAIT__);
}
}
trait person {
public $age;
public $birthday;
public function eat() {
echo '<br>I don\'t like eating.';
}
}
trait animal {
public function eat() {
echo '<br>What?';
}
}
class super {
use student, person, animal {
student::say as private _say;
student::eat insteadof person, animal;
}
public function say() {
$this->_say();
printf('<br>I\'m %d years old. ', $this->age);
}
}
$s = new super();
$s->name = 'Tom';
$s->age = 15;
$s->say();
$s->eat();