3.6 ACCESSING METHODS AND PROPERTIES USING THE $this
VARIABLE
During the execution of an object’s method, a special variable called $this is
automatically defined, which denotes a reference to the object itself. By using
this variable and the -> notation, the object’s methods and properties can be
further referenced. For example, you can access the $name property by using
$this->name (note that you don’t use a $ before the name of the property). An
object’s methods can be accessed in the same way; for example, from inside one
of person’s methods, you could call getName() by writing $this->getName().
