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.
Protected access modifier
Protected is only accessible within the class in which it is defined and its parent or inherited classes.
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).