DEV Community

StuartCreed
StuartCreed

Posted on • Updated on

Static and Non-static in PHP

The difference between static and non static members is only that a non static member is tied to an instance of a class although a static member is tied to the class, and not to a particular instance.
That is, a static member is shared by all instances of a class although a non static member exists for each instance of class.

The difference between self:: and $this
self:: is for static methods and it references the static methods and properties in the class from which it is called.

$this is for non static methods and references non static methods and properties in the class from which it is called.

Top comments (1)

Collapse
 
stuartcreed profile image
StuartCreed

Thanks Erick, I have updated the post :)