The Method Of A Child Class Overriding That Of Its Parent

 
    <html>
<head>
<title>The Method of a Child Class Overriding That of Its Parent</title>
</head>
<body>
<?php
class FirstClass{
    var $name = "first class";
    function FirstClass( $n ){
        $this->name = $n;
    }
    function sayHello(){
        print "Hello my name is $this->name<br />";
    }
}class second_class extends FirstClass {
     function sayHello(){
        print "say hi<br />";
     }
}$test = new second_class("new name");
$test->sayHello();?>
</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.