Resolve the role of call_user_func_array in php
- 2020-06-07 04:09:39
- OfStack
1. Call the method directly
function test($a, $b)
{
echo ' test 1 : '.$a.$b;
}
// call test methods ,array("asp", 'php') Corresponding parameters
call_user_func_array('test', array("asp", 'php'));
2. Call a method in a class through a class
class test2{
function phpSay($a, $b)
{
echo ' test 2 : '.$a.$b;
}
}
$o = new test2();
// Is equivalent to: $o->phpSay('php',' hello ');
call_user_func_array(array(&$o, 'phpSay'), array('php',' hello '));