In PHP 5, what is the difference between using const
and static
?
When is each appropriate? And what role does public
, pr
Declaring a class method or property as static makes them accessible without needing an instantiation of the class.
A class constant is just like a normal constant, it cannot be changed at runtime. This is also the only reason you will ever use const for.
Private, public and protected are access modifiers that describes who can access which parameter/method.
Public means that all other objects gets access. Private means that only the instantiated class gets access. Protected means that the instantiated class and derived classes gets access.