Is it possible in some way to instantiate a class inside a namespace, in a method in another class inside another namespace? And with the requested class instantiated from a variable?
Example:
Class to be loaded from loader-class:
namespace application/pages; class loader { private function __construct() { echo 'Class loaded...'; } } Loader-class:
namespace system/loader; class loader { private $vars; private function __construct($vars) { $this->vars = $vars; } private function load_class() { require(CLASSES . $this->vars['namespace'] . '/' . $this->vars['class'] . ".php"); use $this->vars['namespace']; return new \$this->vars['namespace']\$this->vars['class'](); } } Sorry for the bit confusing formulation, but i couldn't think of better way to ask the question.
Thanks.