Skip to content

Instantly share code, notes, and snippets.

@colindecarlo
Created April 8, 2013 13:05
Show Gist options
  • Save colindecarlo/5336634 to your computer and use it in GitHub Desktop.
Save colindecarlo/5336634 to your computer and use it in GitHub Desktop.
Execute a method in the parent of the parent class
<?php
class A
{
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function showData()
{
printf("Hello I'm class %s and data is: %s\n", get_class($this), $this->data);
}
}
class B extends A
{
public function showData()
{
printf("Yo dawg, data is all like this: %s\n", $this->data);
}
}
class C extends B {}
$myC = new C("ah ha!");
$myC->showData();
$rm = new ReflectionMethod('A', 'showData');
$rm->invoke($myC);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment