Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 782943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:28:00+00:00 2026-05-14T20:28:00+00:00

Lets say I have a parent class class parent { } ….. This parent

  • 0

Lets say I have a parent class

class parent { }

.....

This parent has three sub class

class child1 { }

class child2 { }

class child3 { }

and these child classes have further smaller parts like

class child1subpar1 { }

class child1subpar2 {

       public function foo() {
          echo "hi";
       }

}

class child2subpar1 { }

class child2subpar2 { }

Now, how to sum this whole up like

class child1 extends child1subpar1, child1subpar2 { }
class child2 extends child2subpar1, childsubpar1 { }

class parent extends child1,child2,child3 { }

I need to execute the methods in its inherited classes and do something like this

$objparent = new parent;
$objparent -> foo();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:28:00+00:00Added an answer on May 14, 2026 at 8:28 pm

    No, but multiple inheritance is generally considered a bad practice. You should favor composition instead, so you just use instances of classes you wanted to inherit inside your class.

    And now when I look into your question again, it’s not even an inheritance issue, you should use composition. Maybe if you provided more detail what you expect that class to do, we should answer more accurately.

    UPDATE:

    You will need to create one method for each of these classes’ method which you would want to use – it’s called Facade design pattern. Or maybe you are not aware that you can call methods of inner objects like this:

    $parent->subObject->subSubObject->wantedMethod();
    

    Facade pattern:

    http://en.wikipedia.org/wiki/Facade_pattern

    in your case facade wouldn’t be anything else than creating one class and define every single method you want to use, and inside that method calling any method of any of your inner instances. But i really don’t see any benefit coming from this instead of calling
    instances and methods hierarchically

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 394k
  • Answers 394k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer STBuffer is in meters. More info here. To convert, miles… May 15, 2026 at 2:25 am
  • Editorial Team
    Editorial Team added an answer Following is just a theory and might not work, I'm… May 15, 2026 at 2:25 am
  • Editorial Team
    Editorial Team added an answer Why is there a select there? is that even necessary?… May 15, 2026 at 2:25 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.