About the previous note:
Of course you cannot declare public attributes/methods private, because it can break code relying on access to such an attribute/method. But of course your children can override private with protected/public.
![]() | VisibilityThe visibility of a property or method can be defined by prefixing the declaration with the keywords: public, protected or private. Public declared items can be accessed everywhere. Protected limits access to inherited and parent classes (and to the class that defines the item). Private limits visibility only to the class that defines the item. Members VisibilityClass members must be defined with public, private, or protected.
Method VisibilityClass methods must be defined with public, private, or protected. Methods without any declaration are defined as public.
![]()
LoN_Kamikaze at gmx dot de
28-Mar-2006 05:26
About the previous note:
c3 at epetersen dot org
07-Feb-2006 09:50
Note that you cannot change visibility in a child defined in the parent:
r dot wilczek at web-appz dot de
05-Jan-2006 09:11
Beware: Visibility works on a per-class-base and does not prevent instances of the same class accessing each others properties!
thc at forestfactory dot de
14-Dec-2005 01:38
To jfk...
jfk at 206-225-86-169 dot dedicated dot abac dot net
13-Dec-2005 09:14
BEWARE!! The visibility of a class member can easily be compromised by attaining a reference to the protected member. In C++ for example this can not be done unless specifically included in the declaration/definition. However in PHP it is simple!!!! Observe....
gugglegum at gmail dot com
02-Sep-2005 07:58
When you call parent method from child class, inside parent method $this contains object of child class, but private members depends on from which context you access private property:
gugglegum at gmail dot com
02-Sep-2005 06:14
Private visibility actually force members to be not inherited instead of limit its visibility. There is a small nuance that allows you to redeclare private member in child classes.
gugglegum at gmail dot com
02-Sep-2005 02:01
Parent class can access protected members of its childs.
Miguel <miguel at lugopolis dot net>
21-Jul-2005 11:10
A note about private members, the doc says "Private limits visibility only to the class that defines the item" this says that the following code works as espected:
David Rech
07-Jun-2005 06:14
You may define grouped variables separated by commas if they have the same visibility. This works for both initialized and uninitialized variables. | ![]() | ||