Default visibility of class methods in PHP

The default is public. The reason probably is backwards compatibility as old code expects it to be public (it would stop working if it weren't public).


Default is public. It's a good practice to always include it, however PHP4 supported classes without access modifiers, so it's common to see no usage of them in legacy code.

And no, PHP has no package visibility, mainly because until recently PHP had no packages.


Default is public.

Class methods may be defined as public, private, or protected. Methods declared without any explicit visibility keyword are defined as public.

http://www.php.net/manual/en/language.oop5.visibility.php