I think that the approach is incorrect here. You should think on a factory pattern when using an anonymous/indirect way of creating an object. Make a static factory method in class and call is with something like: $obj =& call_user_function_array('Factory::createUser', array('bob',1234))); and define: class Factory { function &createUser($name, $number) { return new User($name, $number); } } Of course you could abstract the factory method even further by passing the classname, and making use of several options, from: return new $className($par1, $par2); to: $o = new $className(); call_user_function_array(array(&$o, 'init'), array($par1, $par2)); return $o; Or variations thereof, like passing an assoc array of params instead of multiple params, to make thing more uniform. A good place to read about and learn design patterns: http://hillside.net/patterns/ HTH --- "Lam, Chun Matthew" <clam@hotjobs.com> wrote: > Not sure if it will work. > > -----Original Message----- > From: Lam, Chun Matthew [mailto:clam@hotjobs.com] > Sent: Wednesday, February 05, 2003 11:06 AM > To: 'php-objects@yahoogroups.com' > Subject: RE: [php-objects] object instantiation and call_user_func_array > > > Try this > > create_user_func_array("new User",array("bob","1234"); > > > -----Original Message----- > From: Rob [mailto:rcherry@jamwarehouse.com] > Sent: Wednesday, February 05, 2003 4:17 AM > To: php-objects@yahoogroups.com > Subject: [php-objects] object instantiation and call_user_func_array > > > Hi there, > > Is there any way to use call_user_func_array to instantiate an object?? > > Basically I have the follwing: > > class User { > > function User($name, $number) { > > } > > } > > In another .php file I try the following > > include once ("User.inc") > > create_user_func_array("User",array("bob","1234"); > > I have also tried > > create_user_func_array("User::User",array("bob","1234"); > > I always get the following error > > call_user_func_array() expects first argument, 'User', to be a valid > callback in > > What does this mean? Is there any way to create objects on the fly and > dynamically pass through > parameters to the constructor?? > > Thanks > > --- > Rob ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/saFolB/TM ---------------------------------------------------------------------~-> Look here for Free PHP Classes of objects: http://phpclasses.UpperDesign.com/ To unsubscribe from this group, send an email to: php-objects-unsubscribe@egroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/