$this is a reference to the current object.
It can only be used in classes.
From manual:
$this , . $ ( , , , , , ).
:
class Classname
{
public $message = "The big brown fox... jumped....";
function showMessage()
{
echo $this->message;
}
}
$my_object = new Classname();
$my_object->name = "Hello World!";
$my_object->showMessage();
$this :
Classname::showMessage(); // Will throw an error:
// `$this` used while not in object context