Possible Duplicate:
What does $this mean in PHP?
What is the use of $this
?
I'm getting the result correctly on both the following cases.
Without
$this
class Car { function Beetle($colour) { return $colour; } } $car = new Car(); echo $car->Beetle("Blue");
With
$this
class Car { function Beetle($colour) { $this->colour = $colour; return $colour; } } $car=new Car(); echo $car->Beetle("Blue");
On both the cases, I'm getting the same result: "Blue."
I don't understand why and for what we are using $this
.