0

I am using PHP and iam not understanding the concept of inheritance,I need to access the method in the base class from the inherited class,I created a base class object and called the method using the object,The method was declared in protected mode but now i am not even able to access the methods.Why it is like that?
Any reply is valued the most.
Any reply is appreciated more and also Thanks in adv
please help me I need to solve this problem

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by mschroeder
0

Your question has less to do with inheritance and more to do with visibility in php.
(http://www.php.net/manual/en/language.oop5.visibility.php)

Generally speaking:

  • Public - When a method or variable is defined as public it can be called outside the scope of the class or by any class which inherits it.
  • Protected - When a method or variable is defined as protected it can only be called from within the class it was defined or within any class which inherits it.
  • Private - When a method or variable is defined as private it can only be called from the class which it was defined in.

I can elaborate if needed or provide some examples, but there is great beginner information already in the manual or on other tutorial sites.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.