04-18-2009, 02:51 PM
|
#8 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Salathe
To access the property directly ($instance->property), yes it needs to be public. Also note that with private, any classes that extend the class will not have access to it. If you want extending classes to be able to 'see' the private property then it will need to instead be protected.
|
Thanks Salathe,
I think I am a long ways before I write another class extending another class. haha...but I understand.
public - anyone from anywhere can access the property
private - only accessible within the class
protected - only accessible within the class and child classes that have been extended...
And the rules work exactly the same way for methods too? Not just properties....right?
|
|
|
|