OK, I write a simple PHP engine. I have a main class, called engine_class.php in the root, and sub classes in a subfolder called plugins. I've already wrote a autoloader etc, but here comes the problem.
The "engine_class.php":
// Autoloader ..
class engine {
// Declarations, functions, etc...
function __call ($name, $args) {
$this->$name = new $name;
return call_user_func_array(array($this->$name, $name), $args);
}
}
(I've already created some sub-classes... cookie, mysql...)
Now i want, in example (index.php):
include "engine_class.php";
$engine = new engine;
// static
$engine->cookie()::set("name", "value"); // I know that this don't work
// or non-static
$engine->mysql("localhost", "test", "test", "test");
$engine->mysql()->query("SELECT * FROM test");
Now, how can I do, that my sub-classes wil work like in my upper example in/with the main class?
So, that i can use it like this:
$engine = new engine; $engine->[subclass]()->[submethod]($arg1, $arg2, ...); // or for static: $engine->[subclass]()::[submethod]($arg1, $arg2, ...);


Sign In
Create Account

Back to top









