![PHP Access Modifier](http://www.tutorialpath.com/wp-content/uploads/2019/02/PHP-Access-Modifier-1024x672.jpg)
Access Specifiers in PHP
There are three types of Access Specifiers available in PHP, Private, Protected and Public.
Public: Class members declared public can be accessed everywhere.
Protected: Class members declared protected can be accessed only within the class itself and by inheriting classes.
Private: Class members declared as private may only be accessed by the class that defines the member.
Public Access modifier
Public Access modifier is open to use and access inside the class definition as well as outside the class definition.
![public access modifier](http://www.tutorialpath.com/wp-content/uploads/2019/02/public-access-modifier.png)
Output:
![public access modifier output](http://www.tutorialpath.com/wp-content/uploads/2019/02/public-access-modifier-output.png)
Protected access modifier
Protected is only accessible within the class in which it is defined and its parent or inherited classes.
![protected access modifier](http://www.tutorialpath.com/wp-content/uploads/2019/02/protected-access-modifier-1024x709.png)
Output:
![protected access modifier output](http://www.tutorialpath.com/wp-content/uploads/2019/02/protected-access-modifier-output.png)
Private access modifier
Private is only accessible within the class that defines it.( it can’t be access outside the class means in inherited class).
![private access modifier Example](http://www.tutorialpath.com/wp-content/uploads/2019/02/private-access-modifier-Example.png)
Output:
![Private Access Modifier](http://www.tutorialpath.com/wp-content/uploads/2019/02/private-access-modifier-output.png)
Good work boss
Thanks bro