I think my question is kind of noobish but i can't figure out how this stuff is working with PHP. It is a autoloaded class and I want to use my logging class for it.
I know I could have $log also as instance variable but I want it like that.
namespace Bal\Blub;
$log = new Logger('activities');
$log->pushHandler(new StreamHandler(__DIR__.'/../../log/activties.log', Logger::DEBUG));
$log->debug("is working here");
class Foo {
public function bar() {
global $log;
$log->debug("this is my message");
}
}
I don't understand why $log has no value in that case...
Edit: Of course I meant global and not public.
global? I just see a public class property, never assigned. How does Foo knows $log is an instace of the Logger class?global.