Inheritance and over-riding...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Inheritance and over-riding...

Post by LonelyProgrammer »

Which output function will be called in the case of the code below?

Code: Select all

class A
{
   A() { }

   greet() { echo "Greetings from A!"; }

   output() { $this->greet(); }

}

class B extends A
{
  B() { parent::A(); }

  greet() { echo "Greetings from B!"; }

  output() { parent::output(); }
}
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: Inheritance and over-riding...

Post by McGruff »

The child. Full explanation in the manual.
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Post by LonelyProgrammer »

Thanks!
Post Reply