My apologies if my title is not clear, please let me explain...
I have a template class call 'page', when I initialize it I can set it up to be in debug mode by setting $mode.
The problem is I also have a database class and I would like to share the fact that 'page' is in debug mode but don't know the best way to do it...I cannot have 'page' extends 'db' and no where does 'page' actually call the 'db' class. It is always happening on other classes.
Again, sorry if this is unclear...I tried to provide a really simple version of the code to help...
class page {
public $mode; // what mode the page is in (debug/normal)
public function __construct($constructVars) {
$this->mode = $constructVars["mode"]; //debug
}
public function debug($message){
if ($this->mode == "debug"){
$fh = fopen("debug.txt", 'a') or die("can't open debug file");
fwrite($fh, date("Y-m-d H:i:s")." : ".$message."
");
fclose($fh);
}
}
}
class db extends PDO {
public function debugOutput() {
$page = new page();
if ($page->mode == "debug"){
$fh = fopen("debug.txt", 'a') or die("can't open debug file");
fwrite($fh, $message."
");
fclose($fh);
}
}
}
Just to reiterate because I think it is the answer that is going to come up, I can not extend page to include db.