1, the function of the formal parameters can have more than one
2. The data type of the formal parameter can be any type supported by PHP.
3. The name of the function, like a custom variable, must begin with a letter or an underscore.
4, the function of the variable is a local variable, outside the function does not take effect.
5, the function name is case-insensitive.
6. When using global variables, you can use variables that are outside the function.
Examples of using global variables:
<?php
$a = 12;
Function abc () {
Global $a; Representation in the range of function ABC, using the $a outside of functions
$a +=45;
}
ABC ();
echo $a;
?>
Output: 57
7, in order to prevent the chaos of global variables, if you do not want to use a variable, you can use Unset ($var) to delete a variable.
<?php
$a = 12;
Function ABC ($a) {
unset ($a); Indicates that the $a is not used in the ABC function, and that a new definition is needed later.
$a = 45;
}
ABC ($a);
echo $a; Output 12
?>
8, in the PHP function, you can assign a default value for some parameters .
Cases:
<?php
Function ABC ($b, $a = 2) {
$res = $a + $b;
return $res;
}
$e = 70;
Echo ABC ($E). '||';
Echo ABC ($e, 90);
?>
Output: 72| | 160
9, php default value delivery, if you need to refer to (address) delivery, use the & variable name .
Cases:
<?php
$a = 213;
Function ABC (& $b) {
$b = 314;
}
ABC ($a);
echo $a; Output 314
?>