staticmeans the value is accessed viaself::$varinstead of$this->var, is not instance-specific (i.e. it’s also available in static methods) and thus ideal for singletons and similar patterns- a
publicvar is accessible from everywhere, i.e. both from inside the class and outside - a
protectedvar is only accessible from inside the class and from classes inheriting from the class where the var is defined - a
privatevar is only accessible from inside the class
Since you are asking about OOP basics, here are some more keywords worth explaining:
- an
abstractclass cannot be instantiated but only used as a base class; a class containing abstract methods must be abstract and a class inheriting from an abstract class must be abstract unless all abstract methods of the base class are actually implemented - a
finalclass cannot be inherited from
1
solved PHP: Property visibilty, static, etc [closed]