Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using traits for multiple inheritance in php
<?php
class Animal {
public function roar() {
echo "Makes animal sounds";
}
}
trait Cat {
public function roar() {
echo "Meowww";
}
}
class Tiger extends Animal {
use Cat;
}
$tiger = new Tiger;
$tiger->roar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.