| // +----------------------------------------------------------------------+ // // $Id: call_user_func_array.php,v 1.2 2007-01-18 09:02:27 kostja Exp $ // /** * Replace call_user_func_array() * * @category PHP * @package PHP_Compat * @link http://php.net/call_user_func_array * @author Aidan Lister * @version $Revision: 1.2 $ * @since PHP 4.0.4 * @require PHP 4.0.1 (trigger_error) */ if (!function_exists('call_user_func_array')) { function call_user_func_array ($function, $param_arr) { $param_arr = (array) $param_arr; // Sanity check if (!is_callable($function)) { if (is_array($function) && count($function) > 2) { $function = $function[0] . '::' . $function[1]; } $error = sprintf('call_user_func_array() First argument is expected to be a valid callback, \'%s\' was given', $function); trigger_error($error, E_USER_WARNING); return null; } // Build argument string $arg_string = ''; $comma = ''; for ($i = 0, $x = count($param_arr); $i < $x; $i++) { $arg_string .= $comma . "\$param_arr[$i]"; $comma = ', '; } // Determine method of calling function if (is_array($function)) { $object =& $function[0]; $method = $function[1]; // Static vs method call if (is_string($function[0])) { eval("\$retval = $object::\$method($arg_string);"); } else { eval("\$retval = \$object->\$method($arg_string);"); } } else { eval("\$retval = \$function($arg_string);"); } return $retval; } } ?>