Notes for call_user_func Functions
Parse error: syntax error, unexpected t_list, expecting t_string in
When using this function today, the above problem is always prompted. The precautions for using the tool are not described in the official manual.
Appendix:
Mixed call_user_func (callback $ function [, mixed $ parameter [, mixed $...])
Any built-in or user-defined functions can be passed, except for the language structures such as array (), echo (), empty (), eval (), exit (), isset (), list (), print (), and unset ().
My problem is that there is a list method name in the object. Therefore, it is in conflict with the language structure list () of the php tutorial.
View instance applications
The call_user_func function is similar to a special method for calling a function. The usage 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
?>
The internal method of calling the class is strange. The method actually uses an array and does not know how developers think about it. Of course, the new method is saved, which is also innovative:
Class {
Function B ($ c)
{
Echo $ c;
}
}
Call_user_func (array ("a", "B"), "111 ");
// Display 111
?>
The call_user_func_array function is similar to call_user_func, but the parameter is passed in another 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
?>