Jump to content

Private, protected & public methods & properties


Jemoh
 Share

Recommended Posts

Can someone plz explain to me what is the difference between private, protected & public methods & properties cz I dnt seem to get it.

Link to comment
Share on other sites

For properties, it specifies at what point can the value be read or changed, and for methods, at what point can they be executed.Private - only within the class that declared it.Protected - only within the class that declared it, and its children (i.e. classes that extend it, as per this part of the manual).Public - at the class that declared it, its children, and at every instance of the object (or in short: at any point).If that's not enough, you'll have to be a little more specific about what you don't understand (with examples and specific questions like "what would happen in the following scenario: [insert code]").

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...