Jaxel
Well-known member
I'm new to Object Oriented Programming... I've always been more procedural. But for now I'm trying to make some global variables. I have a class, with about 15 functions within it. At the top of all 15 of those functions, I am declaring several variables. Redundant code pisses me off, so I'm trying to figure out how to declare and use those variables globally within the function... What I've tried so far doesn't work...
This is a cut of my class: (a lot of code has been removed to make this neater)
Ideally, what this prints out should be:
However, it only prints out:
As you can clearly see, I'm either not globally writing to the public $perms variable, or I'm not accessing it correctly. Does anyone know what I'm doing wrong?
This is a cut of my class: (a lot of code has been removed to make this neater)
Code:
class EWRporta_ControllerPublic_Wiki extends XenForo_ControllerPublic_Abstract
{
public $perms;
public function actionIndex()
{
$this->perms = $this->getPermissions();
echo "Index: ";
print_r($this->perms);
return $this->responseReroute(__CLASS__, 'Wiki');
}
public function actionWiki()
{
echo "<br />Wiki: ";
print_r($this->perms);
}
}
Ideally, what this prints out should be:
Code:
Index: Array ( [view] => 1 [edit] => 1 [create] => 1 [delete] => 1 [admin] => 1 )
Wiki: Array ( [view] => 1 [edit] => 1 [create] => 1 [delete] => 1 [admin] => 1 )
However, it only prints out:
Code:
Index: Array ( [view] => 1 [edit] => 1 [create] => 1 [delete] => 1 [admin] => 1 )
Wiki: