Skip to content

Instantly share code, notes, and snippets.

@gamunax
Created November 21, 2018 22:26
Show Gist options
  • Save gamunax/852017c154a902810126c701c17f9962 to your computer and use it in GitHub Desktop.
Save gamunax/852017c154a902810126c701c17f9962 to your computer and use it in GitHub Desktop.
Clase Publica en php
<?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