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

From: Date: Tue, 15 Dec 2009 07:28:45 +0000
Subject: note 95136 added to function.call-user-func-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-163985@lists.php.net to get a copy of this message
I use reflection class and also detect whether arguments are passed by reference or passed by value and then initiate/call the method successfully with those arguments: if (count($args) > 1) { if (method_exists($class_name, '__construct') === false) { exit("Constructor for the class <strong>$class_name</strong> does not exist, you should not pass arguments to the constructor of this class!"); } $refMethod = new ReflectionMethod($class_name, '__construct'); $params = $refMethod->getParameters(); $re_args = array(); foreach($params as $key => $param) { if ($param->isPassedByReference()) { $re_args[$key] = &$args[$key]; } else { $re_args[$key] = $args[$key]; } } $refClass = new ReflectionClass($class_name); $class_instance = $refClass->newInstanceArgs((array) $re_args); } Looking for you comments/ideas on this implementation. ---- Server IP: 202.89.58.1 Probable Submitter: 202.70.148.186 ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func-array.php Edit -- https://master.php.net/note/edit/95136 Del: integrated -- https://master.php.net/note/delete/95136/integrated Del: useless -- https://master.php.net/note/delete/95136/useless Del: bad code -- https://master.php.net/note/delete/95136/bad+code Del: spam -- https://master.php.net/note/delete/95136/spam Del: non-english -- https://master.php.net/note/delete/95136/non-english Del: in docs -- https://master.php.net/note/delete/95136/in+docs Del: other reasons-- https://master.php.net/note/delete/95136 Reject -- https://master.php.net/note/reject/95136 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163985) next »