What is the difference between accessing a class method via -> and via ::?
The ->
is for accessing properties and methods of instantiated objects. The ::
is to access static methods, constants or overridden methods.
For more information:
::
is used for accessing static methods or attributes, so you don't have to instantiate an object of the containing class.
->
is used for accessing methods or attributes of instantiated objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With