PHP warns when the number of arguments < The number of parameters, because the interpretation mechanism of PHP will assume that the parameter is defined and not used, it is likely to affect the function of functions. So a warning is issued. However, when the number of arguments > The number of parameters, PHP is not an error, it will only take a few previous parameters, the extra will be discarded.
To write a function in PHP, when calling a function in general, the changed value is a formal parameter instead of an argument. But if you add an address character to a formal parameter, you change the value of the argument, why?
Take a look at the following example:
Copy Code code as follows:
<?php
Write a function swap () to test that the function's argument value does not change
function swap ($a, $b) {
echo "<p> enter SWQP () function before <br>\n";
echo "before Exchange: formal parameter a= $a, formal parameter b= $b <br>\n";
$c = $b;
$a = $b;
$b = $c;
After echo Exchange: Formal parameter a= $a, formal parameter b= $b <br>\n ";
echo "Exits the Swap () function <br></p>\n";
}
$variablea = 5;
$variableb = 10;
echo "Before calling the Swap () function:";
echo "Real parameter a= $variablea, the actual parameter b= $variableb <br>\n";
Swap ($variablea, $variableb);
Echo calls the swap () function: ";
echo "Real parameter a= $variablea, the actual parameter b= $variableb <br>\n";
?>
Copy Code code as follows:
<?php
To test the value of a swap () function argument
Function Swap1 (& $a,& $b) {
echo "<p> enter Swap1 () function <br>\n";
echo "before Exchange: formal parameter a= $a, formal parameter b= $b <br>\n";
$c = $b;
$a = $b;
$b = $c;
After echo Exchange: Formal parameter a= $a, formal parameter b= $b <br>\n ";
echo "Exits the Swap () function <br></p>\n";
}
$variablea = 5;
$variableb = 10;
echo "Before calling the Swap1 () function:";
echo "Real parameter a= $variablea, the actual parameter b= $variableb <br>\n";
Swap1 ($variablea, $variableb);
echo "calls the Swap1 () function:";
echo "Real parameter a= $variablea, the actual parameter b= $variableb <br>\n";
?>
The above two examples is the explanation, has consulted ~ ~ ~ ~