$this and self
Understand how to use the $this keyword with the object operator to access non-static properties and methods within PHP classes. Learn to use the self keyword with the scope resolution operator to access static members. This lesson clarifies the difference and practical use cases of $this versus self in object-oriented PHP programming.
We'll cover the following...
We'll cover the following...
$this
The pseudo-variable $this refers to a member of a class according to an instance of that class. It provides a reference to the calling object, that is the object to which the method or property belongs to. Note that the member of the class must be non-static.
The Object Operator
The -> symbol is a built-in construct in ...