I know that this is a real stupid question, but I don’t really understand something, I use them everyday, but I’m not sure how they work.
class Bootstrap
{
public static $frontController = null;
public static $root = '';
What’s the diff between public static, protected, public…all of them? and when it’s best to use each of one…
Best Regards
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 patternspublicvar is accessible from everywhere, i.e. both from inside the class and outsideprotectedvar is only accessible from inside the class and from classes inheriting from the class where the var is definedprivatevar is only accessible from inside the classSince you are asking about OOP basics, here are some more keywords worth explaining:
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 implementedfinalclass cannot be inherited from