PHP OOP : Access Modifier (public, protected, private)

What is the access modifier?

Restrictions on properties and methods.

Types of access modifier

  1. public
  2. protected
  3. private

Public :

  • Access on base as well as derived class and outside of the class.
  • Everyone can see and access the data.
  • Not secure.
  • Override use.

Protected :

  • Base and Derived class.
  • No one gets access throughout the class.
  • Declare like protected property and method.
  • Not use override function.
  • Without permission no one can access any of these (properties & method).

Private :

  • Access itself.
  • Highly secured.
  • No one can access without permission.
  • Highly costly.
vikashdev k
Latest posts by vikashdev k (see all)
Tagged : / / / / / / / / / / / / / / /
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x