Simply write a small example and you'll see.
Example: Enter a string in a text box separated by commas, and then click Submit to automatically remove the comma concatenation together.
Like this
Click Submit past Return 12345
This small example uses the proxy function call, first of all, to say the name Call_user_func_array ();
Call_user_func_array (' function name to invoke ', ' value of call ');
Write the submission form first:
<form method=post action= "test.php" > enter a string separated by commas: <input type= "text" name= "str" ><BR/>< Input type= "Submit" name= "button" value= "Commit" ></form>
Then write the code that accepts the validation:
<?php function content () {$sum =func_get_args (), if (Empty ($sum)) {echo ' Please enter content! '; return;} $num = "; for ($i =0; $i <count ($sum); $i + +) {$num. = $sum [$i];} echo $num;} if (Isset ($_post[' button ')) {$str =$_post[' str ']; $array =explode (', ', $str); Call_user_func_array (' content ', $array); }
Explanation: 1. First judge the submitted content, and then "," the string into an array ($array) 2. Define a function, get the value of the pass and break it into an array ($sum), return ' Please enter ' if no content is passed, and then make a loop to print a few values from the $sum array and use '. ' Link 3. Because a function cannot be called across a variable field (so to speak, it is understood anyway, so good to understand, do not hit me qaq), so use the proxy function call (Call_user_func_args ()) 4. Use Call_user_func_array (' content ', $array); Let this function call for us, this code is similar to
function content ($a) {//code block}content ($array);
5. This completes the proxy invocation of a function, which is usually used when we cannot invoke the function we write. 6. What's wrong with the place welcome to point out, anyway, I'm not going to change ~qaq~~qaq~.
A small case of proxy function invocation in PHP