[PHP] Re: dynamic object instances

2005-08-11 Thread Thomas Angst
Eli schrieb: You're right that using eval() slows.. But using the _init() function as you suggested is actually tricking in a way you move the constructor params to another function, but the initialization params should be sent to the constructor! I guess that it would be better if PHP will

Re: [PHP] Re: dynamic object instances

2005-08-11 Thread Jochem Maas
Thomas Angst wrote: Eli schrieb: You're right that using eval() slows.. But using the _init() function as you suggested is actually tricking in a way you move the constructor params to another function, but the initialization params should be sent to the constructor! I guess that it would

Re: [PHP] Re: dynamic object instances

2005-08-11 Thread Jochem Maas
Eli wrote: Jochem Maas wrote: Eli wrote: ? $obj_eval=return new $class(; for ($i=0; $icount($args); $i++) $obj_eval.=\$args[$i],; $obj_eval=substr($obj_eval,0,-1).);; $obj=eval($obj_eval); ? I believe that this is the kind of clever, evil stuff the OP was trying to avoid... (evil -

[PHP] Re: dynamic object instances

2005-08-10 Thread Matthew Weier O'Phinney
* Thomas Angst [EMAIL PROTECTED]: I would like to create an object inside a function with its classname and a parameter list submitted by the function call. function create($class, $parameter) { $obj = new $class($parameter); return $obj; } This is working very well. But I have

Re: [PHP] Re: dynamic object instances

2005-08-10 Thread Thomas Angst
Matthew Weier O'Phinney schrieb: Use the func_* functions, along with array_shift(). In addition, you'll need to use either a standard-named static instantiator, or the class name as the constructor method: function create($class) { $args = func_get_args(); array_shift($args); // remove

Re: [PHP] Re: dynamic object instances

2005-08-10 Thread Eli
Thomas Angst wrote: Thanks for you answer, but sorry, I do not understand your hint. I tried this code: class test { var $txt; function test($txt) { $this-txt = $txt; } function out() { echo $this-txt; } } $obj = call_user_func_array(array('test', 'test'), array('foobar'));

Re: [PHP] Re: dynamic object instances

2005-08-10 Thread Jochem Maas
Eli wrote: Thomas Angst wrote: Thanks for you answer, but sorry, I do not understand your hint. I tried this code: class test { var $txt; function test($txt) { $this-txt = $txt; } function out() { echo $this-txt; } } $obj = call_user_func_array(array('test', 'test'),

Re: [PHP] Re: dynamic object instances

2005-08-10 Thread Eli
Jochem Maas wrote: Eli wrote: ? $obj_eval=return new $class(; for ($i=0; $icount($args); $i++) $obj_eval.=\$args[$i],; $obj_eval=substr($obj_eval,0,-1).);; $obj=eval($obj_eval); ? I believe that this is the kind of clever, evil stuff the OP was trying to avoid... (evil - eval :-) -