Visibility of PHP properties and methods
![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
No issues specified. Please specify issues, or remove this template. |
![]() |
![]() |
The visibility of PHP properties and methods refers to visibility in PHP. It is defined using the keywords "public," "private," and "protected." The default is public, if only var is used; "var" is a synonym for "public." Public declared items can be accessed everywhere. Protected limits access to inherited classes (and to the class that defines the item). Private limits visibility only to the class that defines the item.[1] Objects of the same type have access to each others private and protected members even though they are not the same instances. PHP's member visibility features have sometimes been described as "highly useful."[2] However, they have also sometimes been described as "at best irrelevant and at worst positively harmful."[3]
References