in the following example, i will assign some variables that belong to a class. But are assigned inside one of the function/methods. If you only assign it as $example and not as $this->example, it does not assign that variable to the entire class, only in that method/function.
class myClass
{
var $example;
var $example2;
function say_what()
{
$example = 'Hi';
$this->example2 = 'Hi again';
echo '$example: '.$example."<br/>";
echo '$example2: '.$example2."<br/>";
echo '$this->example: '.$this->example."<br/>";
echo '$this->example2: '.$this->example2."<br/>";
}
function say_again()
{
echo '$example: '.$example."<br/>";
echo '$example2: '.$example2."<br/>";
echo '$this->example: '.$this->example."<br/>";
echo '$this->example2: '.$this->example2."<br/>";
}
}
$convo = new myClass();
$convo->say_what();
$convo->say_again();
// this is $convo->say_what();
$example: Hi
$example2: //blank
$this->example: //blank
$this->example2: Hi again
// this is $convo->say_again();
$example: //blank
$example2: //blank
$this->example: //blank
$this->example2: Hi again // only this one assigned to class shows.