1

I have a function in a parent class that calls several functions in the parent class using $this->functionName(). In a child I override functionName. When I run it still calls as if it was parent::functionName():

class Foo {

    function MainCall(){
        $this->Bard();
    }

    private function Bard(){
        echo "HI";
    }
}

class Bar extends Foo {

    private function Bard(){
        echo "bye";
    }
}

$dnew = new Bar();
$dnew->MainCall();

The above code run and echos "HI" but I want bye.

AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
Tolure
  • 859
  • 1
  • 14
  • 34

0 Answers0