0 votes
4 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 12 views
0 votes
1 answer 732 views
0 votes
1 answer 11.8k views
asked Aug 19, 2016 in General by Shed
0 votes
1 answer 3.7k views
+2 votes
1 answer 988 views
...