class Grandpa
{
public function __construct()
{
echo 'Grandpa
';
}
}
class Papa extends Grandpa
{
public function __construct()
{
echo 'Papa
';
parent::__construct();
}
}
class Kiddo extends Papa
{
public function __construct()
{
// THIS IS WHERE I NEED TO CALL GRANDPA'S
// CONSTRUCTOR AND NOT PAPA'S
echo 'Kiddo
';
Grandpa::__construct();
}
}
$instance = new Kiddo;
class Grandpa
{
public function __construct()
{
echo 'Grandpa
';
Kiddo::hello();
}
}
class Papa extends Grandpa
{
public function __construct()
{
echo 'Papa
';
parent::__construct();
}
}
class Kiddo extends Papa
{
public function __construct()
{
// THIS IS WHERE I NEED TO CALL GRANDPA'S
// CONSTRUCTOR AND NOT PAPA'S
echo 'Kiddo
';
Grandpa::__construct();
}
public function hello()
{
echo 'Hello
';
}
}
$instance = new Kiddo;
$papa = new Papa;
if ($this instanceof Kiddo) Kiddo::hello();