Notes on call_user_func function
parse error: syntax error, unexpected t_list, expecting t_string in
I kept getting the above problem when using this function today. Referring to the official manual, there is no introduction to the precautions for using it.
Attachment:
mixed call_user_func ( callback $function [, mixed $parameter [, mixed $... ]] )
Any built-in or user-defined function can be passed, except language constructs such as array(), echo(), empty(), eval(), exit(), isset(), list(), print() and unset( ).
My problem is that there is a method name called list in the object. Therefore, it conflicts with the language structure list() of the PHP tutorial.
See example application
The call_user_func function is similar to a special method of calling a function. The method of use is as follows:
function a($b,$c)
{
echo $b;
echo $c;
}
call_user_func('a', "111","222");
call_user_func('a', "333","444");
//Display 111 222 333 444
?>
It is strange to call the method inside the class. It actually uses array. I don’t know what the developer thought about it. Of course, new is omitted, which is also full of novelty:
class a {
function b($c)
{
echo $c;
}
}
call_user_func(array("a", "b"),"111");
//Display 111
?>
The call_user_func_array function is very similar to call_user_func, except that the parameters are passed in a different way to make the parameter structure clearer:
function a($b, $c)
{
echo $b;
echo $c;
}
call_user_func_array('a', array("111", "222"));
//Display 111 222
?>