call_user_func_array使用原型

If you need to call object and class methods in PHP < 4.0.4, the following code ought to do the trick:

<?php
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;
    }
}
?>
原文地址:https://www.cnblogs.com/wangluochong/p/3383596.html