6.8. Access Types
Access types allow developers to restrict access to members of their classes. They are new to PHP 5, but are a well-known feature of many object-oriented languages. Access types provide a fundamental building block of reliable object-oriented applications and are a crucial requirement for reusable object-oriented infrastructure libraries.
Like C++ and Java, PHP features three kinds of access types: public, private, and protected. A class member may be one of these. If you do not specify an access type, the member is public. You may give an access type to a static member, in which case the access type should precede the static keyword.
Public members can be accessed with no restrictions. Any code outside of the class may read ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access