Jump to content

access class member


lenerd3000

Recommended Posts

is there's a way how can i access parent class member in another class?

 

class test

{

    function t();{}

}

 

class test2 extends test

{

    function t2();{}

}

 

class test3 extends test

{

    function t3();

    {

          // can i access t2 from here which is also a member of test class?

    }

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/103912-access-class-member/
Share on other sites

I think my sight was funny that day. For some reason or another I thought you were using the old fashioned constructor methods (i.e. for class test, you have a method called test). However, i realise you're not ... my bad.

 

Anywho, the method (t2) that you were interested in using from test3 is a sibling method, and not a parent method. You can't utilise sibling methods as this breaks the fundamental rule of inheritance ;)

Link to comment
https://forums.phpfreaks.com/topic/103912-access-class-member/#findComment-539727
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.