note 91565 added to function.call-user-func-array

From: Date: Wed, 17 Jun 2009 10:19:45 +0000
Subject: note 91565 added to function.call-user-func-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-156957@lists.php.net to get a copy of this message
If you want to use call_user_func_array to call an objects constructor, this works for me: $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. ---- Server IP: 92.48.74.199 Probable Submitter: 78.105.152.226 ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func-array.php Edit -- https://master.php.net/note/edit/91565 Del: integrated -- https://master.php.net/note/delete/91565/integrated Del: useless -- https://master.php.net/note/delete/91565/useless Del: bad code -- https://master.php.net/note/delete/91565/bad+code Del: spam -- https://master.php.net/note/delete/91565/spam Del: non-english -- https://master.php.net/note/delete/91565/non-english Del: in docs -- https://master.php.net/note/delete/91565/in+docs Del: other reasons-- https://master.php.net/note/delete/91565 Reject -- https://master.php.net/note/reject/91565 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156957) next »