Created
January 12, 2013 14:51
-
-
Save jamband/4518377 to your computer and use it in GitHub Desktop.
PHP: trait example
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 | |
trait Trait1 | |
{ | |
public function a() | |
{ | |
echo 'a1'; | |
} | |
} | |
trait Trait2 | |
{ | |
public function a() | |
{ | |
echo 'a2'; | |
} | |
} | |
class Class1 | |
{ | |
use Trait1, Trait2 { | |
Trait2::a insteadof Trait1; | |
} | |
} | |
$c = new Class1(); | |
$c->a(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment