You are on page 1of 1

PHP5 Tutorial OOPS PHP5 Class Access Specifiers public, private and protected In the earlier tutorials we have

ve witnessed keywords like public, private and protected. These are nothing but access specifiers. So, lets understand what access specifiers are. Definition of Access Specifiers Access specifiers specify the level of access that the outside world (i.e. other class objects, external functions and global level code) have on the class methods and class data members. Access specifiers can either be public, private or protected. Why do we need Access specifiers Access specifiers are used as a key component of Encapsulation and Data Hiding. By using either of the access specifiers mentioned above i.e. public, private or protected you can hide or show the internals of your class to the outside world. Explanation of each access specifier 1. Private 2. Protected 3. Public

You might also like