문제

I have an Error class that has public static method db_log_error() and private method _log().

db_log_error() calls the _log() method.

When I try $this->_log() I get PHP Fatal error: Using $this when not in object context

When I try self::_log() I get PHP Strict Standards: Non-static method Error::log() should not be called statically

So what is the best approach for what I am trying to do?

도움이 되었습니까?

해결책

Most ideal solution: Make the _log() method static.

Or, disable strict standards:

error_reporting(E_ALL ^ E_STRICT);

다른 팁

Make the log method static as well, if it needs to be called from a static context.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top