Created
November 27, 2016 11:44
-
-
Save gorkamu/5d7bb69fe3bb5aa68a8a17c7273cf2d8 to your computer and use it in GitHub Desktop.
Ejemplo del orden de procedencia en los traits
This file contains hidden or 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 correr() { | |
echo 'Estoy corriendo '; | |
} | |
} | |
trait movimientos { | |
public function correr() { | |
parent::correr(); | |
echo 'y soy feliz'; | |
} | |
} | |
class Perro extends Animal { | |
use movimientos; | |
} | |
$p = new Perro(); | |
$p->correr(); // Estoy corriendo y soy feliz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment