Published on
-1 min read

$this is a special variable, Its reffers to current object. To access a private or protected property we need this keyword for accessing them.

So, $this -> means current object.


public function getProduct()
  return $this->type;

This function is reffering the ‘type’ property of the current object of getProduct method.

We use -> operator for accessing an object’s property or method.

Note 1: Method is just function inside of class.

Note 2: When we are accessing a property or method we should omit the ‘$’ (Dollar) sign.

Thank you.