How to return Current Object in a Static function in PHP
I neet access to current object in a static method.
Code:
protected static $name;
public static function name($modulename)
{
self::$name = $modulename;
}
public function __call($name, $arguments)
{
$me = new test(self::$name);
return $me->$name($arguments);
}
I want to be able to call method log in Log class. L开发者_运维百科ike this
echo Mods::name("Log")->log("test")
;
Sounds like you want a Singleton pattern:
http://www.talkphp.com/advanced-php-programming/1304-how-use-singleton-design-pattern.html
Employ log as a singleton and have Mods::name call Log::getInstance();
精彩评论