Created
March 15, 2014 20:03
-
-
Save amacgregor/9573105 to your computer and use it in GitHub Desktop.
Using traits for multiple inheritance in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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