0 votes
33 views
in General by
When and why should I use public, private, and protected functions and variables inside a class? What is the difference between them?

1 Answer

0 votes
by
  • Public scope to make that property/method available from anywhere, other classes and instances of the object.
  • Private scope when you want your property/method to be visible in its own class only.
  • Protected scope when you want to make your property/method visible in all classes that extend current class including the parent class.

Related questions

0 votes
1 answer 66 views
0 votes
1 answer 770 views
0 votes
1 answer 11.9k views
asked Aug 19, 2016 in General by Shed
0 votes
1 answer 3.8k views
+2 votes
1 answer 1.1k views
...