Created
December 3, 2016 16:00
-
-
Save gorkamu/b334afe1d346d31a614e3069a674a737 to your computer and use it in GitHub Desktop.
Ejemplo de uso del Operador de Resolución de Ámbito en la herencia.
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 PutoAmo | |
{ | |
protected function saluda() { | |
echo "Hola"; | |
} | |
} | |
class Gorkamu extends PutoAmo | |
{ | |
// Sobrescritura de definición parent | |
public function saluda() | |
{ | |
// Pero todavía se puede llamar a la función parent | |
parent::saluda(); | |
echo " soy Gorkamu\n"; | |
} | |
} | |
$gorkamu = new Gorkamu(); | |
$gorkamu->saluda(); // Hola soy Gorkamu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment