Skip to content

Instantly share code, notes, and snippets.

@amacgregor
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amacgregor/9573439 to your computer and use it in GitHub Desktop.
Save amacgregor/9573439 to your computer and use it in GitHub Desktop.
Multiple traits extended example
<?php
class Animal {
public function roar() {
echo "Makes animal sounds";
}
}
trait Feline {
public function roar() {
echo "Meowww";
}
}
trait BigCat {
public function kill() {
echo "Kill an animal";
}
}
class Tiger extends Animal {
use Feline;
use BigCat;
}
class Cat extends Animal {
use Feline;
}
// Cat class example
$cat = new Cat;
$cat->roar();
// Tiger class example
$tiger = new Tiger;
$tiger->roar();
$tiger->kill();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment