PHP Access property of a class from within a class instantiated in the original class.
- by Iain
I'm not certain how to explain this with the correct terms so maybe an example is the best method...
$master = new MasterClass();
$master->doStuff();
class MasterClass {
var $a;
var $b;
var $c;
var $eventProccer;
function MasterClass()
{
$this->a = 1;
$this->eventProccer = new EventProcess();
}
function printCurrent()
{
echo '<br>'.$this->a.'<br>';
}
function doStuff()
{
$this->printCurrent();
$this->eventProccer->DoSomething();
$this->printCurrent();
}
}
class EventProcess {
function EventProcess() {}
function DoSomething()
{
// trying to access and change the parent class' a,b,c properties
}
}
My problem is i'm not certain how to access the properties of the MasterClass from within the EventProcess-DoSomething() method? I would need to access, perform operations on and update the properties. The a,b,c properties will be quite large arrays and the DoSomething() method would be called many times during the execuction of the script. Any help or pointers would be much appreciated :)