note 91565 deleted from function.call-user-func-array by cmb

From: Date: Sun, 30 Aug 2015 18:10:47 +0000
Subject: note 91565 deleted from function.call-user-func-array by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203514@lists.php.net to get a copy of this message
Note Submitter: al dot james at NOSPAMGMAIL dot com ---- If you want to use call_user_func_array to call an objects constructor, this works for me: <?php $obj = new $object_class(); call_user_func_array(array($obj, '__construct'), $args); ?> (However it does depend on having a constructor where all arguments are optional, which may or may not be possible) So this is a two part initiation, the object gets initiated with no arguments first (hence requiring options constructor params), and then __construct gets called again. Thus, you should not do anything in your constructor that triggers effects outside the class... it should just set the objects state.

« previous php.notes (#203514) next »