What is the difference between private and protected members of a class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between private and protected members of a class?

What is the difference between private and protected members of a class?

15th Feb 2018, 7:30 PM
Aleksandr
1 Answer
+ 15
Members declared protected can be accessed only within the class itself and by inheriting and parent classes. Members declared as private may only be accessed by the class that defines the member. http://php.net/manual/en/language.oop5.visibility.php
15th Feb 2018, 7:41 PM
NezhnyjVampir