-
-
Save gamunax/852017c154a902810126c701c17f9962 to your computer and use it in GitHub Desktop.
Clase Publica en php
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 | |
class Abuelo | |
{ | |
public $nombre = 'Jose Perez'; // variable de tipo privado | |
} | |
class Padre extends Abuelo | |
{ | |
function getNombreAbuelo() | |
{ | |
echo $this->nombre; | |
} | |
} | |
$objetoPadre = new Padre(); | |
echo $objetoPadre->getNombreAbuelo(); //muestra Jose Perez, | |
$objAbuelo = new Abuelo(); | |
echo $objAbuelo->nombre; //muestra Jose Perez, cuando es public puede ser accedido sin realisar ninguna herencia |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment