1. call_user_func
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 internal methods of the class. Actually, array is used, and developers do not know how to consider it. Of course new is saved, which is also innovative: class a {function B ($ c) {echo $ c ;}} call_user_func (array ("a", "B"), "111"); // display 111?>
2. call_user_func_array
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?> // The call_user_func_array function can also call the Class ClassA {function bc ($ B, $ c) {$ bc = $ B + $ c; echo $ bc ;}} of the internal methods of the Class ;}} call_user_func_array (array ('classa ', 'bc'), array ("111", "222"); // display 333?>
Call_user_func and call_user_func_array Functions Support reference, which makes them more functional than normal function calls:
Function a (& $ B) {$ B ++;} $ c = 0; call_user_func ('A', & $ c); echo $ c; // display 1call_user_func_array ('A', array (& $ c); echo $ c; // display 2