[Solved] PHP: Property visibilty, static, etc [closed]


  • static means the value is accessed via self::$var instead 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 public var is accessible from everywhere, i.e. both from inside the class and outside
  • a protected var is only accessible from inside the class and from classes inheriting from the class where the var is defined
  • a private var is only accessible from inside the class

Since you are asking about OOP basics, here are some more keywords worth explaining:

  • an abstract class 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 final class cannot be inherited from

1

solved PHP: Property visibilty, static, etc [closed]