<?php class Foo { protected static $a = 1; protected $b = 2; public function func() { echo 'foo' . static::$a . $this->b; } } class Bar extends Foo { protected static $a = 3; protected $b = 4; public function func() { echo 'bar' . static::$a . $this->b; } } $obj = new Bar(); $obj->func(); // Prints 'bar' $parentClassString = get_parent_class($obj); $newObj = new $parentClassString; // Gotta love PHP for magic like this $newObj->func(); // Prints 'foo'
You have javascript disabled. You will not be able to edit any code.