Re: How to dynamically call a constructor like call_user_func_array

From: Date: Thu, 27 Nov 2008 12:30:12 +0000
Subject: Re: How to dynamically call a constructor like call_user_func_array
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-51173@lists.php.net to get a copy of this message
Hi, Christian Weiske wrote:
I want to create a new instance of a class (which name I don't know) and I want to expand a given array to be the constructor's parameters: $clsname = 'mycls'; $val = array('value1', 'value2'); $obj = new mycls($val[0], $val[1]); // This line needs to be dynamic.
call_user_func_array().
Won't work, he'll have to use either eval() or Reflection.
Couldn't find on the php site how to do this.
This is a theme for the php general mailing list.
Definitely...

« previous php.pear.dev (#51173) next »