note 95136 deleted from function.call-user-func-array by danbrown

From: Date: Tue, 15 Dec 2009 16:38:25 +0000
Subject: note 95136 deleted from function.call-user-func-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163995@lists.php.net to get a copy of this message
Note Submitter: sarfraznawaz2005 at gmail dot com ---- 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.

« previous php.notes (#163995) next »