Skip to content

Instantly share code, notes, and snippets.

@gorkamu
Created November 27, 2016 11:44
Show Gist options
  • Save gorkamu/5d7bb69fe3bb5aa68a8a17c7273cf2d8 to your computer and use it in GitHub Desktop.
Save gorkamu/5d7bb69fe3bb5aa68a8a17c7273cf2d8 to your computer and use it in GitHub Desktop.
Ejemplo del orden de procedencia en los traits
<?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