A function can have a return statement, or it can have no. When do you need it? is when you want to receive the result of the function execution, you need a return statement.
After the function finishes executing the return statement, the code after the return statement is never executed.
Return in PHP generally can only get a return value by return, if you want to get multiple return values, you can return an array.
1 <? PHP 2 3 function SayHello ($a,$b)4{5 return $a; 6 return $b ; 7 }89 ?>
You want to get two return values through two return statements, but the result is that you can only return a value.
Shows an example of returning an array with return.
The SayHello function returns an array by return, uses the variable temp to receive the array, and then outputs the returned value through the Foreach loop.
PHP Learning Note-return statement