Back to Developer Roadmap

Access Specifiers

src/data/roadmaps/php/content/[email protected]

4.0708 B
Original Source

Access Specifiers

Access specifiers, also known as access modifiers, in PHP are keywords used in the class context which define the visibility and accessibility of properties, methods and constants. PHP supports three types of access specifiers: public, private, and protected. 'Public' specified properties or methods can be accessed from anywhere, 'private' ones can only be accessed within the class that defines them, while 'protected' ones can be accessed within the class itself and by inherited and parent classes. Here's an illustrative example:

Visit the following resources to learn more: