Re: [PHP] Re: dynamic object instances

2005-08-11 Thread Jochem Maas
Eli wrote: Jochem Maas wrote: Eli wrote: I believe that this is the kind of clever, evil stuff the OP was trying to avoid... (evil - eval :-) - besides eval is very slow - not something you (well me then) want to use in a function dedicated to object creation which is comparatively sl

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 b

[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-10 Thread Eli
Jochem Maas wrote: Eli wrote: I believe that this is the kind of clever, evil stuff the OP was trying to avoid... (evil - eval :-) - besides eval is very slow - not something you (well me then) want to use in a function dedicated to object creation which is comparatively slow anyway (try

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', 'te

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 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 $

[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. Bu