tags:

views:

38

answers:

1

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. Like this

echo Mods::name("Log")->log("test");

How do i do that?

+2  A: 

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

webbiedave
Yep i fixed it { self::$name = $modulename; return new self; }
streetparade