开发者

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();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜