0

Function differences in return and echo

Why use return when echo does the same as return? Example. Here is a function that returns the res. function mult($num1, $num2) { $res = $num1 * $num2; return $res; } Mult(3,5); And here is code that echos the res. function mult($num1, $num2) { $res = $num1 * $num2; Echo $res; } Mult(3,5); The answer will be same. Same results. Right? So can someone help me understand what and when and how and why to use return.

15th Apr 2020, 5:36 PM
vanquer mazambi
vanquer mazambi - avatar
1 Respuesta