<html> <head> <title>Calling an Overridden Method</title> </head> <body> <?php class FirstClass{ var $name = "Joe"; function FirstClass( $n ) { $this->name = $n; } function sayHello() { print "my name is $this->name<br>"; } }
class second_class extends FirstClass { function sayHello() { print "calling method from parent class -- "; FirstClass::sayHello(); } }
$test = new second_class("sub class"); $test->sayHello();