reference: read up in the [man]oop[/man] section of the manual
lets design a class:
class Foo
{
var $myvar;
function Foo( $myvar )
{
$this->myvar = $myvar;
}
function bar()
{
echo "we have {$this->myvar} in here<br>";
}
function callbar()
{
$this->bar();
}
}
$this is a special variable that when used inside of a class, referes to itself, the specific instance of the variable you are executing code form.
when you are executing code within the class, you need to be able to distinguish between a local variable $myvar, and the one variable that belongs to the class iteself as defined by 'var $myvar'. The way we do this is with $this->, $this-> says we are talking about this object.
$myobj1 = new Foo( 'myval' );
$myobj2 = new Foo( 'myval' );
both of these execute the same exact code
$this->myvar = $myvar;
but since each was run from inside an object, $myobj1 and $myobj2, i
t refers to each ones specific $myvar.
Functions:
you also use this to run a function defined inside a class, from inside that class...
$myobj1->callbar();
$myobj2->callbar();
again from php's point of view they are both exxecuting the same exact statment
$this->bar();
does this make sense?