A function is a collection of functions. Perform certain functions or operations. . It is meaningless to keep the result after the operation inside the function. The return value is to take the result of the function operation out of the function. Whether it is a custom function or a built-in function. The prototypes are as follows:
function function name (parameter 1, parameter 2...) {
Operation process
return operation result;
}
The function of the return keyword is to return The result of the operation is moved out of the function. To get this value. You can use the = sign to assign a value to a variable.
$var = function name (parameters, if any);
$var can get the operation result inside the function. There are also some functions that have no return value. . For example, var_dump
Pay special attention to it. return value. It just returns the "value" of the operation result, not a specific variable. For example:
<?php function f1($x){ $sum=1; for($i=$x;$i>0;$i--){ $sum*=$i; } return $sum; } $a=f1(5); echo $a; ?>