Was spricht gegen eine Init-Methode, die vom Konstruktor aufgerufen wird?
ungetestet:
PHP-Code:
class test {
public function __construct () {
if (0 != func_num_args ()) {
call_user_func_array (array ($this , 'init') , func_get_args ());
}
}
public function init () {
// whatever;
}
}
function func ($class) {
$params = func_get_args ();
$OBJ = new array_shift ($params);
call_user_func_array (array ($OBJ , 'init') , $params);
}
func("Test", 1 , null, true);
PHP-Code:
count(func_num_args());
ist übrigens „doppelt gemoppelt“.