Difference between public, private, protected keywords

public keyword :- variables or function those are public are accessable to inside of any class or outside of the class .. no matter where its defined

private keyword :- variables or functions those are private are only accessable inside of the class where its defined .. in other words its only accessable by it source class or parent class

protected keyword :- variables or function those are protected are only accessable inside of the  parent class or its child classes .. but except those class it is not accessable anyhow ..

we will get more clear concept about the difference when we cover extends keyword .

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s