To keep it simple, lets say I have 3 classes. A main class, an error class and a log class.
The classes are laid out as:
MAIN | ---------------- | | ERROR LOG
Now I want error to write a message to the log file.
Solution 1
Store the Main class in a Session variable. And the access the Log through main.
$_SESSION["Main"]->Log->Write_Error("My Error");
Solution 2
Almost the same as above. I store main in a Session Variable but the I create a global function to access log.
function Write_Error($Message) { $_SESSION["Main"]->Log->Write_Error($Message); }
This ways saves coding time because I don't have to write out the long session reference.
I know there are more ways to do this. But every way I can think of requires you to store the main class in a session variable to access log. Is there a way to access a parent class or a parents parent without doing what I did above ?
Thanks in advance,
Jonathan Pitcher