How do I get a PHP class constructor to call its parent's parent's constructor?

前端 未结 15 1387
滥情空心
滥情空心 2020-11-28 21:38

I need to have a class constructor in PHP call its parent\'s parent\'s (grandparent?) constructor without calling the parent constructor.

//         


        
15条回答
  •  离开以前
    2020-11-28 22:04

    I ended up coming up with an alternative solution that solved the problem.

    • I created an intermediate class that extended Grandpa.
    • Then both Papa and Kiddo extended that class.
    • Kiddo required some intermediate functionality of Papa but didn't like it's constructor so the class has that additional functionality and both extend it.

    I've upvoted the other two answers that provided valid yet ugly solutions for an uglier question:)

提交回复
热议问题