note 74427 added to function.call-user-func-array
| From: | richard_harrison at rjharrison dot org | Date: | Wed, 11 Apr 2007 09:31:23 +0000 |
| Subject: | note 74427 added to function.call-user-func-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125280@lists.php.net to get a copy of this message | ||
If you are thinking of using call_user_func_array to instantiate an object (see comments below using
Reflection) then since v5.1.3 you can use the Reflection::newInstanceArgs() method.
<?php
// arguments you wish to pass to constructor of new object
$args = array('a', 'b');
// class name of new object
$className = 'myCommand';
// make a reflection object
$reflectionObj = new ReflectionClass($className);
// use Reflection to create a new instance, using the $args
$command = $reflectionObj->newInstanceArgs($args);
// this is the same as: new myCommand('a', 'b', 'c');
?>
----
Server IP: 194.145.210.4
Probable Submitter: 195.217.141.65
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func-array.php
Edit -- https://master.php.net/note/edit/74427
Del: integrated -- https://master.php.net/note/delete/74427/integrated
Del: useless -- https://master.php.net/note/delete/74427/useless
Del: bad code -- https://master.php.net/note/delete/74427/bad+code
Del: spam -- https://master.php.net/note/delete/74427/spam
Del: non-english -- https://master.php.net/note/delete/74427/non-english
Del: in docs -- https://master.php.net/note/delete/74427/in+docs
Del: other reasons-- https://master.php.net/note/delete/74427
Reject -- https://master.php.net/note/reject/74427
Search -- https://master.php.net/manage/user-notes.php