What is the access modifier?
Restrictions on properties and methods.
Types of access modifier
- public
- protected
- private
![](https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/10/php5-1.png)
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.
![](https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/10/php6-1024x556.png)
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).
![](https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/10/php7-1024x550.png)
Private :
- Access itself.
- Highly secured.
- No one can access without permission.
- Highly costly.
![](https://www.scmgalaxy.com/tutorials/wp-content/uploads/2021/10/php8-1024x549.png)