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

From: Date: Tue, 06 May 2003 21:30:38 +0000
Subject: note 31858 added to function.call-user-func-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-47602@lists.php.net to get a copy of this message
If you need to call object and class methods in PHP < 4.0.4, the following code ought to do the trick: if (!function_exists('call_user_func_array')) { function call_user_func_array($func, $args) { $argString = ''; $comma = ''; for ($i = 0; $i < count($args); $i ++) { $argString .= $comma . "\$args[$i]"; $comma = ', '; } if (is_array($func)) { $obj =& $func[0]; $meth = $func[1]; if (is_string($func[0])) { eval("\$retval = $obj::\$meth($argString);"); } else { eval("\$retval = \$obj->\$meth($argString);"); } } else { eval("\$retval = \$func($argString);"); } return $retval; } } -- http://www.php.net/manual/en/function.call-user-func-array.php http://master.php.net/manage/user-notes.php?action=edit+31858 http://master.php.net/manage/user-notes.php?action=delete+31858 http://master.php.net/manage/user-notes.php?action=reject+31858

« previous php.notes (#47602) next »