This thing has been bugging me for long and I can’t find it anywhere!
What is the difference when using classes in php between :: and ->
Let me give an example.
Imagine a class named MyClass and in this class there is a function myFunction
What is the difference between using:
MyClass myclass = new MyClass
myclass::myFunction();
or
MyClass myclass = new MyClass
myclass->myFunction();
Thank you
as stated, “::” is for static method calls whereas “->” is for instance method calls
except for when using parent:: to access functions in a base class, where “parent::” can be used for both static and non-static parent methods