Calling an Overridden Method : Method Override : Class PHP Source Code


PHP Source Code » Class » Method Override »

 

Calling an Overridden Method



<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();

?>
</body>
</html>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Method Override