PHP allows access to non-static methods using ClassName:: But Why does it throw error when accessing non-static properties using ClassName::?View other answers to this thread
Learn Something New Everyday,
Connect With The Best Developers!
Statics are STATIC, they exist all the time. NON-STATIC means they only exist after you "new' and assign said resultant object to a variable, and will only exist on that variable. They never actually exist in memory on the class.
That's kind of the POINT of static and non-static... so if you're asking this you kind-of missed the point.
Mohammad Daud Ibrahim If you think about it methods are always static, as their value does not change during runtime and are the same on all instances of said class. Only way to overload them is to create a new class that "extends". Think of them more as being like constants.
Properties on the other hand can have different values for each object instance, with methods they're always the same if the class is the same.
Hence the ability to class overload via typecasting in some languages, or the ability to call a parent class' methods from an extension class.