Method Overriding

In method overriding, we are declaring the same method in child classes as in the parent class with different behavior. The use of method overriding is generally in the case when we do not want to inherit the method behavior in the child class. So we can redeclare that method in a child class with different behavior. This process is called method overriding.

Syntax of Method Overloading

    Class FirstClass {
        function welcome($name){
             echo 'Welcome '.$name;
        function good($timing){
             echo 'GOOD '.$timing;
    Class SecondClass extends FirstClass {
        function welcome($name, $city) {
            echo 'Welcome '.$name.' at '.$city.'.';
    $obj = new SecondClass();
    echo '<br/>';
    $obj->welcome('John', 'New Delhi');


good('Morning!'); echo '
'; $obj->welcome('John', 'New Delhi'); ?>