Ejemplo n.º 1
0
class GrandChildClass extends ChildClass{
	public function __construct(){
		//explicitly call the parent constructor to ensure it is run
		parent::__construct();
	}
	public function runAncestorClassDoSomething02(){
		//access the top level class function by using the class name
		ParentClass::doSomething02();
	}
}

$child = new ChildClass();
$child->doSomething01();	 //access all public and protected members of the parent class 
$child->doSomething02(); //override parent class members
$child->runParentClassDoSomething02();
</code></pre>	
	
	</ol>
<span>
    <?php 
echo "<h3>Instantiate a Penguin that inherits from Bird...</h3>";
require_once "Penguin.php";
$emperor = new Penguin("Black", "Squak");
echo "<h3>Run a function unique to Penguins...</h3>";
$emperor->swim();
echo "<h3>Run a Penguin function the overrides the parent...</h3>";
$emperor->fly();
?>
	</span>
</body>
</html>