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

From: Date: Tue, 20 Dec 2005 13:06:43 +0000
Subject: note 59926 added to function.call-user-func-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-100462@lists.php.net to get a copy of this message
Here is another version of createObjArray() function written here earlier by taylor. Believing that using 'eval()' is at least "dirty", I came to the following solution (with a help of panchous - at phpclub dot ru forums ). This solution utilizes the new Reflection API. <?php function & createObjArray($type, $args = array()) { $reflection = new ReflectionClass($type); $output = call_user_func_array(array(&$reflection, 'newInstance'), $args); return $output; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func-array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59926 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59926&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59926&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100462) next »