$this¶
$this
is a variable that represents the current object. It is different in each object, each method.
$this
is also called a pseudo-variable. It is never explicitly set, but is available as soon as the method starts.
$this cannot be unset, nor assigned a different value than the current object. This means it cannot be used as an argument, for example.
There is no special variable called $that
.
<?php
class x {
private $y = 1;
function foo() {
return $this->y;
}
}
?>
See also PHP $this, The $this keyword