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 8482813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:54:44+00:00 2026-06-10T19:54:44+00:00

Is it possible to either extend an extension of a class e.g.: class a

  • 0

Is it possible to either

extend an extension of a class e.g.:

class a {
}
class b extends a {
}
class c extends b {
}

EDIT:

[or some other way that class c can use functions only defined in b but not in a.]

Well I just notice that my question was kinda messed up. c should be able to use all functions, so of course those of a aswell.

I’ll just accept the answer solving my non-existing problem, in case someone searches for this.

  • 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-06-10T19:54:46+00:00Added an answer on June 10, 2026 at 7:54 pm

    Since PHP 5.4 you can use traits which may be of help to you. You can define two traits, one with the functions that class a has and one containing functions that class b has, but not class a.

    So:

    trait TraitA {
        function a1() { }
        function a2() { }
    }
    
    trait TraitB {
        function b1() { }
        function b2() { }
    }
    

    Then you can define a class a that uses only TraitA, a class b that uses both traits, and a class c that uses only TraitB:

    class a {
        use TraitA
        // contains a1 and a2
    }
    
    class b {
        use TraitA, TraitB
        // contains a1, a2, b1 and b2
    }
    
    class a {
        use TraitB
        // contains b1 and b2
    }
    

    More on traits: http://php.net/manual/en/language.oop5.traits.php
    Keep in mind that you have to pay attention to your function names between different traits. You can’t have the same functionnames in both traits or you’ll get collisions.

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

Sidebar

Related Questions

Is it possible to extend the Page-class in C#'s WPF-toolkit (or, respectively, any other
Is it possible with only one bind to either keyup , keypress or keydown
Here's my use case : public class User extends Model {} public class TableA
I am wondering, if it is possible to use encrypted webservices in WP7, that
Is it possible to specify connection/query timeout for the Oracle database queries? Either on
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
I'm currently delegating the builder method to all of the objects that extend one

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.