Translations:Developers/Object oriented programming in PHP/Properties/14/en


 * public : It's dangerous to declare a property as public, because everybody can change the value anytime and after initializing the property all control over the value gets lost. So don't use the public keyword for properties!
 * protected : Properties declared as protected can be accessed only in the definition of the actual class or of its subclasses. As a consequence not only every method of the class can operate on a protected property, but also every method of the subclasses. And this can lead to incompatibility of code, when subclasses override the protected properties of their superclasses. Use this with extreme care
 * private : All properties should be declared as private to ensure they can be only manipulated by methods of their own class in the class definition and to maintain full control of their values. private declared properties can be accessed only in the class definition of their own class, are excluded from inheritance to subclasses and in this way can't be overridden. This improves both consistency and security of the code.