Last active
August 29, 2015 14:00
-
-
Save emersonbroga/99052960edf32d780859 to your computer and use it in GitHub Desktop.
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 Broga | |
{ | |
public function andar() | |
{ | |
echo 'broga anda...'; | |
} | |
} | |
class Marcelo | |
{ | |
public function correr() | |
{ | |
echo 'marcelo corre...'; | |
} | |
} | |
class Ronnan extends Marcelo | |
{ | |
use Broga; | |
public function nadar() | |
{ | |
echo 'Ronnan nada...'; | |
} | |
} | |
$ronald = new Ronnan(); | |
$ronald->nadar(); // Ronnan nada... | |
$ronald->correr(); // marcelo corre... | |
$ronald->andar(); // broga anda... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment