Jump to content

Visibility of PHP properties and methods

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Tisane (talk | contribs) at 03:37, 8 July 2010 (Created page with 'The '''visibility of PHP properties and methods''' is defined using the keywords "public," "private," and "protected." The default is public, if only [[var (com...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The visibility of PHP properties and methods 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 has sometimes been described as "highly useful,"[2] However, they have also been described as "at best irrelevant and at worst positively harmful."[3]

References