Hi,
I have a class with a function and this function has a subfunction. Why can't I access the classes' variables from the subfunction with $this->variable or better: HOW CAN I??
Example:
class testclass {
function mainfunct() {
echo "From mainfunct(): ".$this->myvar."<br>\n";
function subfunct() {
echo "From subfunct(): ".$this->myvar."<br>\n";
}
subfunct();
}
}
$obj = new testclass;
$obj->myvar = "Hello World";
$obj->mainfunct();
This will output:
From mainfunct(): Hello World
From subfunct():
As you can see the subfunction can't access the variable myvar with $this. Why is that or is there a way to access it (without global $obj and access it that way)?
Thanks,
Matthias