Reputation: 35265
If all methods are public unless they are explicitly defined as something else, is it ever necessary to define a method as public
?
Upvotes: 3
Views: 212
Reputation: 53940
There are two style tendencies in php - the "javaesque" majority considers visibility modifiers very important and uses them actively, in the pythonesque minority (i personally belong to) we think that all that public-private-interface-abstract stuff is nothing more but a waste of RAM.
Upvotes: 1
Reputation: 317119
Well, you answered the question already by naming the default: no, it is not necessary.
Class methods may be defined as public, private, or protected. Methods declared without any explicit visibility keyword are defined as public.
However, I consider it good practise to always do so.
Upvotes: 11